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#ifndef QPLUGINLOADER_H
5#define QPLUGINLOADER_H
6
7#include <QtCore/qglobal.h>
8#if QT_CONFIG(library)
9#include <QtCore/qlibrary.h>
10#endif
11#include <QtCore/qplugin.h>
12
13QT_BEGIN_NAMESPACE
14
15#if QT_CONFIG(library)
16
17class QLibraryPrivate;
18class QJsonObject;
19
20class Q_CORE_EXPORT QPluginLoader : public QObject
21{
22 Q_OBJECT
23 Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
24 Q_PROPERTY(QLibrary::LoadHints loadHints READ loadHints WRITE setLoadHints)
25public:
26 explicit QPluginLoader(QObject *parent = nullptr);
27 explicit QPluginLoader(const QString &fileName, QObject *parent = nullptr);
28 ~QPluginLoader();
29
30 QObject *instance();
31 QJsonObject metaData() const;
32
33 static QObjectList staticInstances();
34 static QList<QStaticPlugin> staticPlugins();
35
36 bool load();
37 bool unload();
38 bool isLoaded() const;
39
40 void setFileName(const QString &fileName);
41 QString fileName() const;
42
43 QString errorString() const;
44
45 void setLoadHints(QLibrary::LoadHints loadHints);
46 QLibrary::LoadHints loadHints() const;
47
48private:
49 QLibraryPrivate *d;
50 bool did_load;
51 Q_DISABLE_COPY(QPluginLoader)
52};
53
54#else
55
56class Q_CORE_EXPORT QPluginLoader
57{
58public:
59 static QObjectList staticInstances();
60 static QList<QStaticPlugin> staticPlugins();
61};
62
63#endif // QT_CONFIG(library)
64
65QT_END_NAMESPACE
66
67#endif // QPLUGINLOADER_H
68

source code of qtbase/src/corelib/plugin/qpluginloader.h