How to get the native QStyle subclass?
It must be really simple, but I can't figure it out:
How do I create a QStyle object that contains the native look and feel of the computer I'm on?
I basically want to write something like this:
QStyle* pNativeStyle = QStyleFactory::createNativeStyle();
...but this method does not exist.
By the time my code runs, the QApplication style has already been tinkered with, so I can't use QApplication::style().
The QStyleFactory does not seem to have an option to simply create "the native style", whichever subclass of QStyle that is.
How do I do it?
Kind regards
Robert
Re: How to get the native QStyle subclass?
yes the style has been created but its not used until you allow it to.
Code:
main()
{
QStyle *nativeStyle
= app.
style();
//do whatever you want to do with style;
//Style would be used now.
mw.show();
return app.exec();
}
Re: How to get the native QStyle subclass?
I'm inside a library that only gets called after the QApplication::style() has already been modified.
Re: How to get the native QStyle subclass?
There is no such thing as a "native style". I'm on Linux, what's my "native style"? You can detect the operating system and based on that and Qt's source code you can check which style gets chosen by Qt by default. But there is no guarantee you are going to choose the right style since a particular style might not be available on a particular compilation.
Re: How to get the native QStyle subclass?
If you want a new unmodified style what the default QApplication has selected on startup, try this.
Code:
qDebug() << s->objectName();