[Qt-interest] Strange stylesheet behaviour

Tr3wory tr3w at freemail.hu
Mon May 25 12:42:09 CEST 2009


Hi!

I create the following project: (TDM MinGW gcc 4.4.0, Qt 4.5.1 Open Source)

StyleSheetTest.pro:
--------------------------------
TARGET = StyleSheetTest
TEMPLATE = app
SOURCES += main.cpp
HEADERS += widget.h

widget.h:
--------------------------------
#ifndef WIDGET_H
#define WIDGET_H

#include <QtGui/QWidget>

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


#endif // WIDGET_H

main.cpp:
-----------------------------
#include <QtGui/QApplication>
#include "widget.h"


int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString stylesheet("* { background-image: url(background.jpeg); }");

    Widget w;
    w.setStyleSheet(stylesheet);
    w.show();

    QWidget qw;
    qw.setStyleSheet(stylesheet);
    qw.show();

    return a.exec();
}

------------------------------------------

When I run the program, the QWidget window show the background, the
Widget window doesn't.

Do I missed something, or it's a bug?

tr3w



More information about the Qt-interest-old mailing list