Qt Application doesn't end on Android platform after calling QMainWindow::close()



  • Hey everybody,
    I'm having so much trouble trying to figure out the problem related to my project. I'm developing a Android application on Qt (5.3.1) and I'm testing it on my smartphone (Samsung S4/Android 4.4) but when I press a button that call the
    QMainWindow::close() method the application just hides but not close. Is someone having the same problem? Do you guys have some idea about the problem. Sincerely,



  • QMainWindow is supposed to close on the QMainWindow instances. It is true with any platform. Did you manipulate any flags like Qt::WA_QuitOnClose ?



  • [quote author="Dheerendra" date="1411030715"]QMainWindow is supposed to close on the QMainWindow instances. It is true with any platform. Did you manipulate any flags like Qt::WA_QuitOnClose ?[/quote]

    I didn't use any Flags. It's too weird because I reimplemented the event close of the QMainWindow and I noticed it isn't even been called. Do you have some suggestions?



  • Where are you trying this ? I experimented with Nexus and application exits. Can you give me your sample source ?

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    Widget m;
    QMainWindow w;
    QPushButton button("pthinks.com",&w);
    w.show();
    QObject::connect(&button,SIGNAL(clicked()),&w,SLOT(close()));
    QObject::connect(&button,SIGNAL(clicked()),&button,SLOT(close()));
    a.exec();

    qDebug() << " I am here "<< endl;
    return 1;
    

    }



  • Actually I did it:
    @#include "mainwindow.h"
    #include <QApplication>
    #include <QPushButton>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    QPushButton b("Ola Mundo",&w);
    //QObject::connect(&b,SIGNAL(clicked()),&w,SLOT(close()));
    QObject::connect(&b,SIGNAL(clicked()),&a,SLOT(closeAllWindows()));
    w.show();
    return a.exec();
    }
    @
    I tried both connections alternating between them and together but the application keep running after the Button has been clicked.
    The application hide but it's still running. I'm using Android SDK API 19 with NDK r9d and Ant 1.9.4. I'm testing it on my T-Mobile Samsung S4 (Android 4.4.2). Does my code work for you? Sincerely,
    [quote author="Dheerendra" date="1411046465"]Where are you trying this ? I experimented with Nexus and application exits. Can you give me your sample source ?

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    Widget m;
    QMainWindow w;
    QPushButton button("pthinks.com",&w);
    w.show();
    QObject::connect(&button,SIGNAL(clicked()),&w,SLOT(close()));
    QObject::connect(&button,SIGNAL(clicked()),&button,SLOT(close()));
    a.exec();

    qDebug(&#41; << " I am here "<< endl;
    return 1;
    

    }
    [/quote]



  • I tried your same application and it works fine for me on Nexus. I am using NDK r10 32 bit, with Qt 5.3.x. It quits. It may be specific issue.



  • [quote author="Dheerendra" date="1411051171"]I tried your same application and it works fine for me on Nexus. I am using NDK r10 32 bit, with Qt 5.3.x. It quits. It may be specific issue.[/quote]
    I will try it on other device and see what happen. I used the r10 on linux and it didn't work again. Thank you for your concerning and I will let you know.



  • Just to clarifiy / preven misunderstanding:

    Do you think the application is still running because it still apears in the list of recently used apps that opens when you hold the menu button down?

    This List does not show running applications! It shows the last used application. Even Java apps remains in the list when they exit.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.