[SOLVED] Menu Bar disappears when the app is restarted



  • Hello all!

    I have an app with a menu bar and a restart process.

    When the app is restarted by the process the menu bar disappears.

    I am using OSX 10.9

    main.cpp
    @
    #include "mainwindow.h"
    #include <QApplication>

    #define CODIGO_RESTART 1000

    int main(int argc, char *argv[])
    {
    int codigoSaida = 0;

    do{
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        codigoSaida = a.exec&#40;&#41;;
    
    }while(codigoSaida == CODIGO_RESTART&#41;;
    
    return codigoSaida;
    

    }
    @

    restart process
    @
    void MainWindow::reiniciar()
    {
    qApp->exit(1000);
    }
    @

    When I call reiniciar function, the app restarts but the menu bar do not appears



  • SOLVED

    @
    int main(int argc, char *argv[])
    {
    int codigoSaida = 0;

    QApplication a(argc, argv);
    
    do{
        a.exit();
    
        MainWindow w;
        w.show();
    
        codigoSaida = a.exec&#40;&#41;;
    
    }while(codigoSaida == CODIGO_RESTART);
    
    return codigoSaida;
    

    }
    @



  • Thank you for sharing your solution.

    a comment.

    I think you don't need a.exit() and the beginning of the loop.

    I tested it on Linux and with QApplication under a loop the app looks ugly on second and later iterations. All styling is gone on second iteration.
    With QApplication out of the loop and without a.exit() everything works fine on Linux.



  • Yes, you are right. I removed the a.exit() and it works fine

    Thanks a lot.


Log in to reply
 

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