View Full Version : Getting the name of the default style
gregsan
27th March 2008, 08:03
Hi,
I have a question regarding the default style name for a given operating system.
I would like to show in my app a combobox with all valid styles (which I can get using QStyleFactory.keys()) and select the style that is the default one for the operating system on which the app is run.
How do I get the default style name?
I already tried the QSettings("Trolltech").value("style"), but the string that I got is empty.
If it's important, I'm using Qt 4.3.3 thru PyQt.
Thanks in advance for the answer...
maverick_pol
27th March 2008, 08:21
You mean style Name: Motif/CDE/ etc ?
Kacper
jpn
27th March 2008, 08:28
In C++ it would be:
QString styleName = QApplication::style()->objectName();
Boron
27th September 2011, 15:01
It is an old thread but nevertheless interesting for my identical task.
There is one thing that does not work for me (Qt 4.7.4):
What jpn suggests return the current style of the application.
But I need the default style an application gets if the style is not manually changed. On WinXP it should return "WindowsXP", on Vista it should return something like "WindowsVista" (I assume).
I need this for configuring my application to "system default style" instead of a manually selected style like WindowsXP, Cleanlooks or...
Boron
28th September 2011, 19:00
(Edit of my previous post is not possible, so this "double post")
What I am doing now to get the "default style" is to ask the QApplication object right after application start for its style before applying a different style.
QString defaultStyleName = qApp->style()->objectName();
qApp->setStyle(/*e.g. Plastique style*/);
// much more code follows and later I want to switch to the default style:
qApp->setStyle(QStyleFactory::create(defaultStyleName));
But this approach fails if someone start teh application with the commandline option -style=<someStyle>. Then my defaultStyleName string would be <someStyle> and NOT the default style Qt uses for the underlaying operating system.
How can the system's default style be determined?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.