Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dialog before main window (i.e. a wizard)
Forum Updated to NodeBB v4.3 + New Features

Dialog before main window (i.e. a wizard)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 430 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SeeLookS Offline
    SeeLookS Offline
    SeeLook
    wrote on last edited by SeeLook
    #1

    Hi,

    I'm looking for the best solution to display a wizard window before a main application window. So far, this is my solution:

    // main.cpp
    auto a = new QApplication(argc, argv);
    // (....)
    auto e = new QQmlApplicationEngine;
    e->rootContext()->setContextProperty(QStringLiteral("GLOB"), GLOB); // some global object for entire QML code
    e->rootContext()->setContextProperty(QStringLiteral("otherGlobal"), &otherGlobal);
    if (GLOB->isFirstRun) {
      e->load(QUrl(QStringLiteral("qrc:/Wizard.qml")));
      a->exec();
      delete e;
      e = new QQmlApplicationEngine;
      e->rootContext()->setContextProperty(QStringLiteral("GLOB"), GLOB);
      e->rootContext()->setContextProperty(QStringLiteral("otherGlobal"), &otherGlobal);;
      GLOB->isFirstRun = false;
     }
     e->load(QUrl(QStringLiteral("qrc:/MainWindow.qml")));
    a->exec();
    (....)
    

    This way I'm calling QApplication::exec() twice, but it seems to not be a problem.
    But there is also a need to delete first instance of QQmlApplicationEngine - otherwise the wizard instance is not destroyed, it disappears only.
    So when the engine instance is created again, I have to again load e->rootContext()->setContextProperty() with those shared objects.

    It works fine, but maybe there is any better way to invoke the wizard before main app window.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved