summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/qmetaobject-revision/main.cpp
blob: 8081f979d37b58017386c8e87d4eb64b10bd8192 (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
// Copyright (C) 2016 Research In Motion.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QApplication>
#include <QMetaObject>
#include <QMetaMethod>
#include <QMetaProperty>
#include <QDebug>
#include "window.h"

void exposeMethod(const QMetaMethod &)
{
}

void exposeProperty(const QMetaProperty &)
{
}

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
//! [Window class using revision]
    Window window;
    int expectedRevision = 0;
    const QMetaObject *windowMetaObject = window.metaObject();
    for (int i=0; i < windowMetaObject->methodCount(); i++)
        if (windowMetaObject->method(i).revision() <= expectedRevision)
            exposeMethod(windowMetaObject->method(i));
    for (int i=0; i < windowMetaObject->propertyCount(); i++)
        if (windowMetaObject->property(i).revision() <= expectedRevision)
            exposeProperty(windowMetaObject->property(i));
//! [Window class using revision]
    window.show();
    return app.exec();
}