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 ++++++------ src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 src/widgets/doc/snippets/qstyleplugin/mystyleplugin.json (limited to 'src/widgets/doc/snippets') 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" ] } + -- cgit v1.2.3