继承 QWidget setStyleSheet无效,解决方法。发现 继承自QWidget的自定义类 ,使用setStyleSheet无效,如果删除头文件中的 Q_OBJECT,setStyleSheet生效,但不用OBJECT 就无法所使用signal and slot,最后找到解决办法,继承自QWidget的自定义类中,重载 paintEvent方法,并加入如下代码:QStyleOption opt;opt.init(this);QPainter p(this);style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, t Read More
posted @ 2014-03-21 15:45 星语海蓝 Views(7092) Comments(1) Diggs(0)
qt中关于QWidget的背景颜色和背景图片的设置首先设置autoFillBackground属性为真然后定义一个QPalette对象设置QPalette对象的背景属性(颜色或图片)最后设置QWidget对象的Palette实例:QWidget *widget = new QWidget;widget->setAutoFillBackground(true);QPalette palette;palette.setColor(QPalette::Background, QColor(192,253,123));//palette.setBrush(QPalette::Background Read More
posted @ 2014-03-21 15:11 星语海蓝 Views(676) Comments(0) Diggs(0)