Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Menu Bar disappears when the app is restarted
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Menu Bar disappears when the app is restarted

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    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

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • guidupasG Offline
      guidupasG Offline
      guidupas
      wrote on last edited by
      #2

      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;
      

      }
      @

      Att.
      Guilherme Cortada Dupas

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • guidupasG Offline
          guidupasG Offline
          guidupas
          wrote on last edited by
          #4

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

          Thanks a lot.

          Att.
          Guilherme Cortada Dupas

          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