Sections
Report typeBug Status?Closed Resolution?Fixed
ProductQt Functional areaLook'n'Feel Version found4.3.0
Priority?1 - Highest Scheduled for?4.3.1

Description

As demonstrated by the following example. Using "background-color: red" instead works for both widgets.

#include <QtGui>

class test : public QWidget
{
    Q_OBJECT
public:
    test(QWidget *parent = 0)
        : QWidget(parent)
    {
    }
};

#include "main.moc"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QWidget t1;
    t1.setObjectName("gui");
    t1.setStyleSheet(QString(
        "QWidget#gui {background-image:url(background.png);}"
    ));
    t1.show();

    test t2;
    t2.setObjectName("gui");
    t2.setStyleSheet(QString(
        "QWidget#gui {background-image:url(background.png);}"
    ));
    t2.show();


    return app.exec();
}

Resolution: QWidget, QDialog are special widgets in the sense that they do not have a paintEvent. In Qt, we paint through the backing store. For custom widgets that directly inherit from QWidget and QDialog, one needs to provide a paintEvent as below:

void paintEvent(QPaintEvent *)
{
        QStyleOption opt;
        opt.init(this);
        QPainter p(this);
        style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

Note that the reason background-color works is because the stylesheet code sets up the background brush.

History

2007-06-12 17:48 - Entry created: Task status changed to 'Open', Resolution set to 'Pending', Version found set to '4.3.0', Version for fix set to '4.3.1', Priority changed to '1 - Highest'
2007-06-13 17:17 - Task status changed to 'Active'
2007-06-14 15:11 - Resolution set to 'Fixed'
2007-06-14 15:11 - Task status changed to 'Closed'