In addition, this style also changes the look of:
All other widgets are not affected and are rendered using the native Windows style (Vista, XP or classic Windows, depending on the OS version).
This style sets the default icon size for toolbar buttons to 16x16 pixels. This setting can be changed using the setIconSize
method of the toolbars.
The demo application contains most widgets affected by this style, including the menu bar, toolbar, tab widget, docked windows and a toolbox. It can be compiled on any OS, but it will use the WindowsModernStyle only on Windows.
The first option is the simplest one and it is enabled by default. You just have to add windowsmodernstyle.cpp
and windowsmodernstyle.h
to your project and add the following code just after creating the application object:
#if defined( Q_WS_WIN ) app.setStyle( "windowsmodernstyle" ); #endif
This will switch the default style to WindowsModernStyle if the application was compiled on a Windows system and if the style is avalable.
These two files can also be compiled separately as a plugin library. To do that, create a project containing these two files, using the lib
type and the plugin
option. Also define the WMSTYLE_EXPORT_PLUGIN
macro (by adding it to the DEFINES
variable in the project file). The plugin can then be dynamically or statically linked to the application, depending on the Qt configuration (usually dynamic libraries are used). Refer to the Qt documentation for more details about creating and using plugins.
If you do not want to use the style as a plugin at all, define the WMSTYLE_NO_PLUGIN
macro. In that case you will have to add these files to the application's project and manually create the instance of the WindowsModernStyle class.