Guest User

Untitled

a guest
Feb 19th, 2020
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <QGuiApplication>
  2. #include <QQmlApplicationEngine>
  3.  
  4. #define TRY_Q_NAMESPACE
  5.  
  6. #ifdef TRY_Q_NAMESPACE
  7. namespace MyNamespace {
  8. Q_NAMESPACE
  9.  
  10. enum class SomeEnum {
  11.     Foo,
  12.     Bar
  13. };
  14. Q_ENUM_NS(SomeEnum)
  15. }
  16. #endif
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20.     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  21.  
  22.     QGuiApplication app(argc, argv);
  23.  
  24.     QQmlApplicationEngine engine;
  25.  
  26. #ifdef TRY_Q_NAMESPACE
  27.     qmlRegisterUncreatableMetaObject(MyNamespace::staticMetaObject,
  28.                              "com.kdab.namespace",
  29.                              3, 14,
  30.                              "MyNamespace",
  31.                              "Error: only enums");
  32. #endif
  33.     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  34.     if (engine.rootObjects().isEmpty())
  35.         return -1;
  36.  
  37.     return app.exec();
  38. }
RAW Paste Data