Reputation: 2281
I'm developing a Qt Widgets application and due to compile performance issues, I started developing it in Linux Ubuntu instead of Windows. The problems is that, when compiled and run, the app appears with traditional Ubuntu style instead of Windows (7) style. Since the app is only for Windows, I'ld like to know how can I compile it inside Linux Ubuntu but making it appear with Windows style.
I tried using QApplication::setStyle(QStyleFactory::create("QWindowsStyle"));
in main.cpp, without success. I guess the QtAssistant docs just aren't clear enough on how can I do this change. Any help will be appreciated.
Upvotes: 2
Views: 2086
Reputation: 471
First check out put of QStyleFactory::keys()
then set the look by calling
qApp->setStyle("Windows");
This command will give you windows 98 look. If you want windows vista look you should configure qt sources with -style-windowsvista
and rebuild all sources.
according to http://doc.qt.io/qt-5/qstylefactory.html#details qt style is not platform independent. So IT IS IMPOSSIBLE to have that native look in not windows platform. It's worth mentioning that in windows also Windows SDK
itself is required in order to build sources of Qt otherwise your application will look like windows 98 in windows 7.
Upvotes: 1
Reputation: 98485
It can't be done, since the style's elements are rendered by Windows (or OS X), not by Qt. Qt's style implementation asks the OS libraries to provide bitmaps of those elements. If you wanted to, you could modify the style to use a disk cache for static items. You could then use the style on all platforms. The problem is that these OS-provided bitmaps are a part of the OS and thus non-redistributable.
The only plastform-specific style that at least used to be available everywhere was the old Windows 95 style, in times of Qt 3. I'm not sure what its current status is.
Upvotes: 1
Reputation: 11944
Could you by any chance be using a Qt package that is compiled without the style? Can you try running QStyleFactory::keys() to verify that the style exists?
Upvotes: 1