diff options
author | Amir Masoud Abdol <amirmasoudabdol@icloud.com> | 2022-12-08 14:56:15 +0100 |
---|---|---|
committer | Amir Masoud Abdol <amirmasoudabdol@icloud.com> | 2023-01-18 14:47:12 +0100 |
commit | 7fe2537ce20ebf887d71fe0d0d0fb14b429d68be (patch) | |
tree | e46007589c9ea026769b0ffe3300b8a964ecc119 /examples/widgets/doc/src | |
parent | b171abe69533a83c5b6fea51807da3ad45a1d3f3 (diff) |
Fix Style Plugin Example, and add some CMake Docs
A few things:
- Improved the documentation by adding a CMake section, briefly
describing the process of adding the plugin, and placing it where it
should be.
- Write a note about the case where the style may be overwritten at
launch, and how to set the a new style using a CLI
- Improved the CMake build such that it creates the App Bundle
correctly, and also works without an App Bundle as well.
- Changed the example, and plugin such that now instead of a QPushButton
we have a QTextEdit, and change the text color.
- Replaced the application screenshot
Fixes: QTBUG-107842
Fixes: QTBUG-109227
Change-Id: I161a91b27df016ff6230fac3871b79d2dfbdf18a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'examples/widgets/doc/src')
-rw-r--r-- | examples/widgets/doc/src/styleplugin.qdoc | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/examples/widgets/doc/src/styleplugin.qdoc b/examples/widgets/doc/src/styleplugin.qdoc index c3c4c8d223..cb0fbe15b8 100644 --- a/examples/widgets/doc/src/styleplugin.qdoc +++ b/examples/widgets/doc/src/styleplugin.qdoc @@ -25,20 +25,23 @@ class. Style plugins are loaded by Qt and made available through QStyleFactory; we will look at this later. We have implemented \c SimpleStylePlugin, which provides \c SimpleStyle. The new style - contributes to widget styling by drawing button backgrounds in - red - not a major contribution, but it still makes a new style. + contributes to widget styling by changing the text color of the + text edit widget to red - not a major contribution, but it still + makes a new style. The new style is platform agnostic in the sense that it is not based on any specific style implementation, but uses QProxyStyle to merely tweak the looks in the current application style that defaults to the native system style. - \note On some platforms, the native style will prevent the button - from having a red background. In this case, try to run the example - in another style (e.g., fusion). + \note On some platforms, the native style may overwrite some custom + stylings, e.g., button background color. In that case, try to run + your application in another style (e.g., fusion). You may do this + by passing \c{-style fusion} as a command line argument to your + application. We test the plugin with \c StyleWindow, in which we display a - QPushButton. The \c SimpleStyle and \c StyleWindow classes do not + QTextEdit. The \c SimpleStyle and \c StyleWindow classes do not contain any plugin specific functionality and their implementations are trivial; we will therefore leap past them and head on to the \c SimpleStylePlugin and the \c main() function. After we have looked @@ -96,8 +99,30 @@ In the plugin profile we need to set the lib template as we are building a shared library instead of an executable. We must also set the config to plugin. We set the library to be stored in the - styles folder under stylewindow because this is a path in which Qt - will search for style plugins. + \c{styles} folder next to the main executable because this is a path + in which Qt will search for style plugins. + + \section2 Using CMake to Set up the Simple Style Plugin + + When using CMake, we use \l{qt6_add_plugin}{qt_add_plugin} + to create the \c simplestyleplugin plugin: + + \snippet tools/styleplugin/plugin/CMakeLists.txt 0 + + On Windows and Linux, we place the plugin into the \c{styles} folder + next to the main executable, i.e., \c{styleplugin.exe}: + + \snippet tools/styleplugin/plugin/CMakeLists.txt 2 + + And on macOS, we store the \c simplestyleplugin into the + \c{Contents/PlugIns/styles} folder of the App Bundle. + + \snippet tools/styleplugin/plugin/CMakeLists.txt 1 + + \note On macOS, when creating an App Bundle, store the plugins in + the \c PlugIns folder and not next to the main executable in + the \c MacOS folder as the latter will cause issues during signing + and distribution of the app. \section1 Related Articles and Examples |