[SOLVED] Guide to make your desktop app look the same on the 3 platforms (linux, mac, windows)
-
Hello,
First is it possible?
Second, is there a guide for that somewhere?Cheers,
-
Yes, it is possible and easy. Just hard-code the style in your app, or use an external stylesheet like "QDarkStyleSheet":https://github.com/ColinDuquesnoy/QDarkStyleSheet.
Or run your app with -style flag:
@
myApp.exe -style Fusion
@ -
Thank you Mister AFAIK ;)
-
Hello again,
In your example, there are only native widgets int he qss file. Does that work from subclassed widgets?
(because I am having some issues by setting stylesheet in a clean way with the widgets I subclassed)Cheers
-
It should still work correctly, if you have not changed the widgets too much (by doing custom painting, for example).
-
Will try this thanks ;)
-
Why isn't this working when just manually change the shylesheet in the UI ?
For example, I subclassed QPushButton with no paintEvent,
I do on the widget containing some of these custom pushbuttons:
MyButton{
background-color : black
}
This is not working. Why would there be difference between this and qss file? -
I don't know exactly how you assign the stylesheet.
Is "MyButton" the name of your subclass? -
Hello again. Yes it is my subclass.
Here is how I proceed :
In the ui file, I have one widget with layout. I add several QPushButton to this layout. Then I cast these QPushButton into MYCustomButton class by right clicking in the UI and chosing cast into MyCustomButton.
THen when I right click on the widget and do
MyButton{
background-color : black
}
nothing is happening. -
Then use this:
@
MyCustomButton{
background-color : black
}
@I remember there were some problems with "overwriting" stylesheets (that is, when one global QSS is specified, in some cases further style changes in children will fail). Maybe you have hit a bug. Try setting that new style in C++, and if that fails: add it to the global QSS file.