Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstyleplugin.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include "qstyleplugin.h"
6#include "qstyle.h"
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QStylePlugin
12 \brief The QStylePlugin class provides an abstract base for custom QStyle plugins.
13
14 \ingroup plugins
15 \inmodule QtWidgets
16
17 QStylePlugin is a simple plugin interface that makes it easy
18 to create custom styles that can be loaded dynamically into
19 applications using the QStyleFactory class.
20
21 Writing a style plugin is achieved by subclassing this base class,
22 reimplementing the pure virtual create() function, and
23 exporting the class using the Q_PLUGIN_METADATA() macro.
24
25 \snippet qstyleplugin/main.cpp 0
26
27 The json metadata file \c mystyleplugin.json for the plugin needs
28 to contain information about the names of the styles the plugins
29 supports as follows:
30
31 \quotefile qstyleplugin/mystyleplugin.json
32
33 See \l {How to Create Qt Plugins} for details.
34
35 \sa QStyleFactory, QStyle
36*/
37
38/*!
39 \fn QStyle *QStylePlugin::create(const QString& key)
40
41 Creates and returns a QStyle object for the given style \a key.
42 If a plugin cannot create a style, it should return 0 instead.
43
44 The style key is usually the class name of the required
45 style. Note that the keys are case insensitive. For example:
46
47 \snippet qstyleplugin/main.cpp 1
48*/
49
50/*!
51 Constructs a style plugin with the given \a parent.
52
53 Note that this constructor is invoked automatically by the
54 moc generated code that exports the plugin, so there is no need for calling it
55 explicitly.
56*/
57QStylePlugin::QStylePlugin(QObject *parent)
58 : QObject(parent)
59{
60}
61
62/*!
63 Destroys the style plugin.
64
65 Note that Qt destroys a plugin automatically when it is no longer
66 used, so there is no need for calling the destructor explicitly.
67*/
68QStylePlugin::~QStylePlugin()
69{
70}
71
72QT_END_NAMESPACE
73
74#include "moc_qstyleplugin.cpp"