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

source code of qtbase/src/widgets/styles/qstyleplugin.cpp