From b31501020fa138f7125c1d6bedeb0d64ebd81d6d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 26 Jul 2012 13:56:14 +0200 Subject: Fixup the plugin documentation Move the plugin howto from qtdoc to corelib where it belongs. Fix the snippets and remove all remaining references to Q_EXPORT_PLUGIN Task-number: QTBUG-26237 Change-Id: I43dce2ffa42193b7a992fa1a0f2fcb2f633037b2 Reviewed-by: Casper van Donderen --- src/widgets/doc/snippets/qstyleplugin/main.cpp | 12 ++++++------ .../doc/snippets/qstyleplugin/mystyleplugin.json | 2 ++ src/widgets/styles/qstyleplugin.cpp | 19 +++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json (limited to 'src/widgets') 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 #include +//! [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() */ -- cgit v1.2.3