[Qt-interest] Strange stylesheet behaviour
Girish Ramakrishnan
girish at forwardbias.in
Mon May 25 13:52:34 CEST 2009
You need to provide a paintEvent as documented in and moc'ify -
http://doc.trolltech.com/4.5/stylesheet-reference.html.
Girish
Tr3wory wrote:
> 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