QStyleOption opt
opt.init(this)
QPainter p(this)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this)
QWidget::paintEvent(e)
注意需要包含几个头文件。
方法如下:
设备:华为笔记本。系统:win7。软件:QT CREATOR。版本:8.0.11。
1、打开QT CREATOR,来到并来到设计师designer的编辑界面。
2、在button一栏中,找到push button。
3、拖动到设计界面上面去。
4、在属性中,拉到下面,找到styleSheet点击旁边的省略号。
5、看到编辑样式表。
6、点击添加资源旁边的小三角,选择border-image。
7、选择图片资源,确定。
8、回到样式编辑表,再确定,按钮的背景就变了。
第一个错误frame->setStyleSheet("color:blue")没有color,你这是设置背景颜色frame->setStyleSheet("background:blue")这样就可以了
第二个frame->setStyleSheet("bacground-color:url(images/frame.jpg)")拼写错误background
frame->setStyleSheet(" image: url(xxx.jpg)")这样子的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)