25Mar/110
my damaged brain…
Долго мучился, пока не почитал мануалы. В нужном месте.
Оказывается, что если хочешь для прямого наследника QWidget'а установить background-image через setStyleSheet(), то надо ему переопределить paintEvent():
class MyCustomWidget : public QWidget
{
Q_OBJECT
// ...
}void MyCustomWidget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}* This source code was highlighted with Source Code Highlighter.
http://doc.qt.nokia.com/4.7/stylesheet-reference.html#list-of-stylable-widgets - там в самом конце.
Tagged as: code, qt, QWidget, style sheets
No Comments
hi there! it's my blog. the site is here: silvansky.leadhoster.com.