Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. qt android quit app
Forum Updated to NodeBB v4.3 + New Features

qt android quit app

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 392 Views 1 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.
  • 0xNull0 Offline
    0xNull0 Offline
    0xNull
    wrote on last edited by
    #1

    im trying quit my current app from a thread...

    
    #include <QThread>
    
    class WorkerThread : public QThread
    {
        void run() override {
            qDebug() << "hello world from thread";
            sleep(5000);
            //app.quit(); <= need close app here   
        }
    };
    
    
    func main(){
             /*
                some stuff that create QML interface....
             */
             
             //create thread
             WorkerThread *workerThread = new WorkerThread();
             workerThread->start();
             app.exect()
    }
    
    

    but isn't working... obviusly need reference of app to execute quit function but inside thread i cant pass it like a parameter. is there a way to quit my app without QGuiApplication app reference

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Use the qApp macro to retrieve the application object.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • TomZT Offline
        TomZT Offline
        TomZ
        wrote on last edited by
        #3

        @0xNull said in qt android quit app:

        but isn't working...

        that quit() method is static, you are calling it on an object which is an instance. Don't do that. Try to avoid calling static methods on objects and instead fully specify the name. Like so;

        QApplication::quit();
        

        See docs at; https://doc.qt.io/qt-6/qcoreapplication.html#quit

        1 Reply Last reply
        1

        • Login

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