[Qt-interest] [qt-interest] For classes with namespace style sheets not applied

Anton Chernov mechernov at gmail.com
Thu Mar 24 14:53:59 CET 2011


Had anyone the same problem?

>From help:

---------------------------------
Widgets inside C++ namespaces

The Type Selector can be used to style widgets of a particular type.
For example,
 class MyPushButton : public QPushButton {
     // ...
 }

 // ...
 qApp->setStyleSheet("MyPushButton { background: yellow; }");

Qt Style Sheet uses QObject::className() of the widget to determine
when to apply the Type Selector. When custom widgets are inside
namespaces, the QObject::className() returns <namespace>::<classname>.
This conflicts with the syntax for Sub-Controls. To overcome this
problem, when using the Type Selector for widgets inside namespaces,
we must replace the "::" with "--". For example,
 namespace ns {
     class MyPushButton : public QPushButton {
         // ...
     }
 }

 // ...
 qApp->setSytleSheet("ns--MyPushButton { background: yellow; }");
---------------------------------

ns--MyPushButton is working in a test application, but NOT IN MY APPLICATION!

What can be the trick?



More information about the Qt-interest-old mailing list