Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ========================C++============================
- #include <QGuiApplication>
- #include <QQmlApplicationEngine>
- #include <QtQml/QtQml>
- #include <QDebug>
- class Foo: public QObject {
- Q_OBJECT
- Q_ENUMS(FooEnum)
- public:
- enum FooEnum {
- A,
- B
- };
- };
- class Bar: public QObject {
- Q_OBJECT
- public:
- public slots:
- void notWorkingSlotWithEnumArg(Foo::FooEnum slotValue)
- {
- qDebug() << "notWorkingSlotWithEnumArg slot worked with value:" << slotValue;
- }
- };
- int main(int argc, char *argv[])
- {
- QGuiApplication app(argc, argv);
- qmlRegisterUncreatableType<Foo>("Foo", 1, 0, "Foo"," prefix for enum");
- qmlRegisterType<Bar>("Bar", 1, 0, "Bar");
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
- return app.exec();
- }
- #include "main.moc"
- ========================C++============================
- ========================Qml============================
- import QtQuick 2.2
- import QtQuick.Window 2.1
- import Bar 1.0
- import Foo 1.0
- Window {
- visible: true
- width: 360
- height: 360
- MouseArea {
- anchors.fill: parent
- onClicked: {
- bar.notWorkingSlotWithEnumArg(Foo.A)
- Qt.quit();
- }
- }
- Bar {
- id: bar
- }
- }
- ========================Qml============================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement