Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QApplication>
5#include <QtGui>
6
9{
11 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "mystyleplugin.json")
12public:
13 MyStylePlugin(QObject *parent = nullptr);
14
15 QStyle *create(const QString &key) override;
16};
18
20{
21public:
23
24};
25
27{
28public:
30};
31
36
37QStringList MyStylePlugin::keys() const
38{
39 return QStringList() << "Rocket" << "StarBuster";
40}
41
44{
45 QString lcKey = key.toLower();
46 if (lcKey == "rocket") {
47 return new RocketStyle;
48 } else if (lcKey == "starbuster") {
49 return new StarBusterStyle;
50 }
51 return nullptr;
52}
54
55int main(int argc, char *argv[])
56{
57 QApplication app(argc, argv);
58 MyStylePlugin plugin;
59 return app.exec();
60}
QStyle * create(const QString &key) override
[1]
Definition main.cpp:43
MyStylePlugin(QObject *parent=nullptr)
Definition main.cpp:32
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString toLower() const &
Definition qstring.h:435
The QStylePlugin class provides an abstract base for custom QStyle plugins.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
RocketStyle()
Definition main.cpp:22
int main()
[0]
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLuint64 key
#define Q_OBJECT
#define Q_PLUGIN_METADATA(x)
QApplication app(argc, argv)
[0]
view create()