aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmoduleplugin/plugin.2.2/plugin.cpp
blob: eb405720fbb948a48e590cb57a0a32f14e6a45f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QStringList>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
#include <QDebug>

class MyPluginTypeV2_2 : public QObject
{
    Q_OBJECT
    Q_PROPERTY(int value READ value WRITE setValue)
    Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)

public:
    MyPluginTypeV2_2(QObject *parent = nullptr) : QObject(parent) { qWarning("import2.2 worked"); }

    int value() const { return v; }
    void setValue(int i) { v = i; }

private:
    int v;
};

class MyPluginV2_2 : public QQmlExtensionPlugin
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)

public:
    MyPluginV2_2() { qWarning("plugin2.2 created"); }

    void registerTypes(const char *uri) override
    {
        Q_ASSERT(QLatin1String(uri) == "org.qtproject.AutoTestQmlPluginType");
        qmlRegisterType<MyPluginTypeV2_2>(uri, 2, 2, "MyPluginType");
        qmlRegisterModule(uri, 2, 2);
    }
};

#include "plugin.moc"