Reputation: 368
With
void QApplication::setStyleSheet()
I can set a global style sheet for my Qt application. For example, I set the default background of all QWidgets to black.
However, in the QT Designer all my widgets still have the default looks (grey background), because it doesn't know anything about my code. Is there a way to set a global style sheet to my application that also affects the widgets looks in the QT Designer? Then I wouldn't have to compile my project every time I want to see how it looks. Or is there maybe a more sophisticated way to solve this problem?
Upvotes: 4
Views: 5658
Reputation: 30708
In the Preferences dialog (menu: Settings, Preferences...), there's a section in Forms called "Print/Preview Configuration". You can set a stylesheet there for the preview action (normally on Ctrl+R). This won't change the colour of the form as you edit it, but you can quickly see it as it will appear in your application.
See also my question Can I style the top-level form in Designer preview?
Upvotes: 1
Reputation: 722
There is solution. You can set in Qt Designer your stylesheet for top level widget styleSheet property.
For example: you set style
QWidget {background-color:black;}
for MainWindow form in Qt Designer and all child widgets now have black background.
Upvotes: 4
Reputation: 3989
As you said yourself: It doesn't know anything about your code. So nothing you can do in code. But compiling your project every time you want to see how it looks? One stupid question... don't you know about the preview function in the designer? Press ctrl-alt-r.
Of course, it shows only the style, which is applied to the widget currently loaded in the designer. But you could temporarily set your style sheet to this widget to see how it would look, if you later on set this sheet globally in your program. Not perfect, but at least no need to compile your whole project.
Upvotes: 0