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. QMainWindow Hide( ) and show( )
QtWS25 Last Chance

QMainWindow Hide( ) and show( )

Scheduled Pinned Locked Moved Unsolved General and Desktop
hidesetvisibilityshow
10 Posts 2 Posters 6.1k Views
  • 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.
  • F Offline
    F Offline
    Faruq
    wrote on last edited by Faruq
    #1

    Greetings everyone once again,

    so I begin to explore on the show( ) and hide( ) on QMainWindow.
    I managed to get the results all these while (Dialog will not pop when hide( ) , etc)

    However , only today I realised that putting a hide( )0. Meaning to say that it is still running actually and went on to be stucked due to the omitted show( ) .

    I removed the " MainWindow w; " and w.show()" from main.cpp so that I can put choices/flexibility in my other .cpp file

    //Hide and show 
    void MainWindow::Function(int number){
    
        if (number == 1 ){
        MainWindow::show();
        }
        else if (number == 2){
        MainWindow::hide();           //Doesnt actually exit the dialog/application with code 0
        }
    }
    
    

    How can I hide QMainWindow properly if this is the case?

    EDIT: Let me rephrase my question since I am more clear with the situation. Since it is hidden, how do I exit if the application/dialog is hidden away from me? Should I just enable a connect button (Connect Esc with Exit())?

    jsulmJ 1 Reply Last reply
    0
    • F Faruq

      Greetings everyone once again,

      so I begin to explore on the show( ) and hide( ) on QMainWindow.
      I managed to get the results all these while (Dialog will not pop when hide( ) , etc)

      However , only today I realised that putting a hide( )0. Meaning to say that it is still running actually and went on to be stucked due to the omitted show( ) .

      I removed the " MainWindow w; " and w.show()" from main.cpp so that I can put choices/flexibility in my other .cpp file

      //Hide and show 
      void MainWindow::Function(int number){
      
          if (number == 1 ){
          MainWindow::show();
          }
          else if (number == 2){
          MainWindow::hide();           //Doesnt actually exit the dialog/application with code 0
          }
      }
      
      

      How can I hide QMainWindow properly if this is the case?

      EDIT: Let me rephrase my question since I am more clear with the situation. Since it is hidden, how do I exit if the application/dialog is hidden away from me? Should I just enable a connect button (Connect Esc with Exit())?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Faruq I don't understand the question. hide() does not exit the dialog/application, it just hides the dialog/application window as the name suggests. To exit the application you call http://doc.qt.io/qt-5/qcoreapplication.html#quit (application) or http://doc.qt.io/archives/qt-4.8/qwidget.html#close for dialog.
      Also

      MainWindow::show();
      MainWindow::hide();
      

      is invalid code as neither show() nor hide() are static, you have to call them on actual QMainWindow instance.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Faruq I don't understand the question. hide() does not exit the dialog/application, it just hides the dialog/application window as the name suggests. To exit the application you call http://doc.qt.io/qt-5/qcoreapplication.html#quit (application) or http://doc.qt.io/archives/qt-4.8/qwidget.html#close for dialog.
        Also

        MainWindow::show();
        MainWindow::hide();
        

        is invalid code as neither show() nor hide() are static, you have to call them on actual QMainWindow instance.

        F Offline
        F Offline
        Faruq
        wrote on last edited by
        #3

        @jsulm Ah, I went on to reflect after reading your comment. I understand what is my actual question now.

        Let me rephrase my question. Since it is hidden, how do I exit if the application/dialog is hidden away from me from sight? Should I just enable a connect button (Connect Esc with Exit())?

        jsulmJ 1 Reply Last reply
        0
        • F Faruq

          @jsulm Ah, I went on to reflect after reading your comment. I understand what is my actual question now.

          Let me rephrase my question. Since it is hidden, how do I exit if the application/dialog is hidden away from me from sight? Should I just enable a connect button (Connect Esc with Exit())?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Faruq Do you want that the user exits your app while it is hidden or do you want to exit your app on some condition?
          If you want the user to exit your app then it should not be hidden, else user will not see the UI of your app. So, to me the use case is still unclear.
          A hidden app is still shown in the taskbar and can be closed from there (right click).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          F 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Faruq Do you want that the user exits your app while it is hidden or do you want to exit your app on some condition?
            If you want the user to exit your app then it should not be hidden, else user will not see the UI of your app. So, to me the use case is still unclear.
            A hidden app is still shown in the taskbar and can be closed from there (right click).

            F Offline
            F Offline
            Faruq
            wrote on last edited by
            #5

            @jsulm Thanks for your prompt reply. Appreciate it.

            Hmmm, I am unable to see the hidden app in the taskbar. Where can I find it?

            jsulmJ 1 Reply Last reply
            0
            • F Faruq

              @jsulm Thanks for your prompt reply. Appreciate it.

              Hmmm, I am unable to see the hidden app in the taskbar. Where can I find it?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Faruq Which OS do you use?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              F 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Faruq Which OS do you use?

                F Offline
                F Offline
                Faruq
                wrote on last edited by
                #7

                @jsulm window 10 OS. Nothing shown on the task manager too.

                jsulmJ 1 Reply Last reply
                0
                • F Faruq

                  @jsulm window 10 OS. Nothing shown on the task manager too.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Faruq Then your app is not running. Crash?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  F 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Faruq Then your app is not running. Crash?

                    F Offline
                    F Offline
                    Faruq
                    wrote on last edited by
                    #9

                    @jsulm I don't think so. Qt say it crashes when I run the stop button. But I'm sure it's hiding. I'm going to try to connect the Esc button for quit to see if it I indeed on the background or so. Will be back in a while. :) thank you for your patience in guiding me.

                    F 1 Reply Last reply
                    0
                    • F Faruq

                      @jsulm I don't think so. Qt say it crashes when I run the stop button. But I'm sure it's hiding. I'm going to try to connect the Esc button for quit to see if it I indeed on the background or so. Will be back in a while. :) thank you for your patience in guiding me.

                      F Offline
                      F Offline
                      Faruq
                      wrote on last edited by
                      #10

                      @jsulm I tried. But it cannot be closed as there is nothing to close ( there is no dialog/application in the first place). Haha. its alright. I will continue to explore and see if there is any other way.

                      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