Advertisement
Guest User

Untitled

a guest
May 13th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. ========================C++============================
  2. #include <QGuiApplication>
  3. #include <QQmlApplicationEngine>
  4. #include <QtQml/QtQml>
  5. #include <QDebug>
  6.  
  7. class Foo: public QObject {
  8. Q_OBJECT
  9. Q_ENUMS(FooEnum)
  10. public:
  11. enum FooEnum {
  12. A,
  13. B
  14. };
  15. };
  16.  
  17. class Bar: public QObject {
  18. Q_OBJECT
  19. public:
  20. public slots:
  21. void notWorkingSlotWithEnumArg(Foo::FooEnum slotValue)
  22. {
  23. qDebug() << "notWorkingSlotWithEnumArg slot worked with value:" << slotValue;
  24. }
  25. };
  26.  
  27.  
  28. int main(int argc, char *argv[])
  29. {
  30. QGuiApplication app(argc, argv);
  31. qmlRegisterUncreatableType<Foo>("Foo", 1, 0, "Foo"," prefix for enum");
  32. qmlRegisterType<Bar>("Bar", 1, 0, "Bar");
  33. QQmlApplicationEngine engine;
  34. engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
  35.  
  36. return app.exec();
  37. }
  38.  
  39. #include "main.moc"
  40.  
  41. ========================C++============================
  42. ========================Qml============================
  43.  
  44.  
  45. import QtQuick 2.2
  46. import QtQuick.Window 2.1
  47. import Bar 1.0
  48. import Foo 1.0
  49.  
  50. Window {
  51. visible: true
  52. width: 360
  53. height: 360
  54.  
  55. MouseArea {
  56. anchors.fill: parent
  57. onClicked: {
  58. bar.notWorkingSlotWithEnumArg(Foo.A)
  59. Qt.quit();
  60. }
  61.  
  62. }
  63.  
  64. Bar {
  65. id: bar
  66. }
  67. }
  68.  
  69. ========================Qml============================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement