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. How to quit qml safely?
Forum Updated to NodeBB v4.3 + New Features

How to quit qml safely?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 4.5k 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.
  • S Offline
    S Offline
    sonicss
    wrote on last edited by sonicss
    #1

    Hello all:
    In my application(arm device), the software can be reboot by user. There is my question: when the user click the reboot button, the onClick call the function in c++ to finish the job and reboot the device. but How to quit or exit qm safely?
    I use QQmlApplicationEngine to load my qml files, below is the code

    QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/Main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    

    I read the help file, QQmlApplicationEngine has exit an quit signal

    [signal] void QQmlEngine::quit()
    This signal is emitted when the QML loaded by the engine would like to quit.
    See also exit().

    How to quit engine?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2
      Qt.quit()
      // or
      Qt.exit(someCode)
      

      https://doc.qt.io/qt-5/qml-qtqml-qt.html#exit-method

      (Z(:^

      S 1 Reply Last reply
      3
      • sierdzioS sierdzio
        Qt.quit()
        // or
        Qt.exit(someCode)
        

        https://doc.qt.io/qt-5/qml-qtqml-qt.html#exit-method

        S Offline
        S Offline
        sonicss
        wrote on last edited by
        #3

        @sierdzio tks a lot, I'll try it.

        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