summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/doc/snippets/qstyleplugin/main.cpp12
-rw-r--r--src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json2
-rw-r--r--src/widgets/styles/qstyleplugin.cpp19
3 files changed, 17 insertions, 16 deletions
diff --git a/src/widgets/doc/snippets/qstyleplugin/main.cpp b/src/widgets/doc/snippets/qstyleplugin/main.cpp
index 10a122016f..46554695f7 100644
--- a/src/widgets/doc/snippets/qstyleplugin/main.cpp
+++ b/src/widgets/doc/snippets/qstyleplugin/main.cpp
@@ -41,14 +41,17 @@
#include <QApplication>
#include <QtGui>
+//! [0]
class MyStylePlugin : public QStylePlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE mystyleplugin.json)
public:
MyStylePlugin(QObject *parent = 0);
QStyle *create(const QString &key);
- QStringList keys() const;
};
+//! [0]
class RocketStyle : public QCommonStyle
{
@@ -68,26 +71,23 @@ MyStylePlugin::MyStylePlugin(QObject *parent)
{
}
-//! [0]
QStringList MyStylePlugin::keys() const
{
return QStringList() << "Rocket" << "StarBuster";
}
-//! [0]
//! [1]
QStyle *MyStylePlugin::create(const QString &key)
{
- QString lcKey = key;
+ QString lcKey = key.toLower();
if (lcKey == "rocket") {
return new RocketStyle;
} else if (lcKey == "starbuster") {
return new StarBusterStyle;
}
return 0;
-//! [1] //! [2]
}
-//! [2]
+//! [1]
int main(int argc, char *argv[])
{
diff --git a/src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json b/src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json
new file mode 100644
index 0000000000..64f140c60c
--- /dev/null
+++ b/src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json
@@ -0,0 +1,2 @@
+{ "Keys": [ "Rocket", "Starbuster" ] }
+
diff --git a/src/widgets/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp
index ed68b7cbc1..63d11af963 100644
--- a/src/widgets/styles/qstyleplugin.cpp
+++ b/src/widgets/styles/qstyleplugin.cpp
@@ -57,15 +57,17 @@ QT_BEGIN_NAMESPACE
Writing a style plugin is achieved by subclassing this base class,
reimplementing the pure virtual create() function, and
- exporting the class using the Q_PLUGIN_METADATA() macro. See \l
- {How to Create Qt Plugins} for details.
+ exporting the class using the Q_PLUGIN_METADATA() macro.
- The json metadata file for the plugin needs to contain information
- about the names of the styles the plugins supports as follows:
+ \snippet qstyleplugin/main.cpp 0
+
+ The json metadata file \c mystyleplugin.json for the plugin needs
+ to contain information about the names of the styles the plugins
+ supports as follows:
- \code
- { "Keys": [ "mystyle" ] }
- \endcode
+ \quotefile qstyleplugin/mystyleplugin.json
+
+ See \l {How to Create Qt Plugins} for details.
\sa QStyleFactory, QStyle
*/
@@ -79,10 +81,7 @@ QT_BEGIN_NAMESPACE
The style key is usually the class name of the required
style. Note that the keys are case insensitive. For example:
- \snippet qstyleplugin/main.cpp 0
- \codeline
\snippet qstyleplugin/main.cpp 1
- \snippet qstyleplugin/main.cpp 2
\sa keys()
*/