I'm trying to do some heavy redeisgning of standard widgets using Qt Style Sheets. So after doing most of it manually for different widgets by #objectName
selectors I've decided to group similar widgets in some way.
For example, I have multiple QFrames
which act like headers in inner forms. And I want all of them to have the same stylesheet. One way of doing that is using naming convention (this is my fallback variant), i.e. QFrame[objectName|="prefix_"]
. But I wanted to group my widgets by class. So I created simple placeholder class:
class HeaderFrame: public QFrame
{
public:
HeaderFrame(QWidget *parent = NULL): QFrame(parent) {}
};
Which allowed me to promote all these QFrames
to HeaderFrames
. After that I've tried setting
HeaderFrame { background-color: red; }
stylesheet to MainWindow object itself (to make it act on all HeaderFrames) but it won't work. Nothing is changed in QtCreator form designer and nothing is changed after compiling an application. I've tried different variants of this stylesheet but nothing works.
So, is only Qt widgets (like QLabel, QFrame, etc.) are available for styling this way? Or there is some way to write stylesheet for your promoted widget?