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. Keep previous window open when closing newest window?

Keep previous window open when closing newest window?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k 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.
  • B Offline
    B Offline
    bryanQT1
    wrote on last edited by
    #1

    I am new to QT and am working on a simple application for displaying information for certain data based on user input. To start, I have a login page (1st/main window), which if correct credentials are entered will open the next window, which I will call the 2nd window. When the user enters information to the 2nd window and presses the button, it opens and displays the data in charts. Call this the 3rd window. Following the input from the first window, I call "hide()" and then "show()" for the second window. When the button in the second window is pressed, I only call "show()" which opens the 3rd window. Ideally, the user can close the 3rd window and enter new data into the second window. However, closing the 3rd window also closes the 2nd window. Whats more weird is that I can click on the 2nd window, close it, and use the 3rd window without issue.

    So, why can I not close the 3rd window and keep the 2nd window open? And why can I close the 2nd window without closing the 3rd window (not that this is bad).

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

      Hi and welcome to devnet,

      Are you implementing each of these widgets in the preceding one ?

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

      B 1 Reply Last reply
      1
      • B Offline
        B Offline
        bryanQT1
        wrote on last edited by
        #3

        I believe I may have accidentally created the windows as “dialog without buttons”. Not sure if that would cause such an issue.

        But no, each of the windows has their own implementation. The header file of the windows has an object of the new window which it will open, and I use that to call NewWindowVarNamw->show()

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Are you implementing each of these widgets in the preceding one ?

          B Offline
          B Offline
          bryanQT1
          wrote on last edited by
          #4

          @SGaist
          I was able to fix this by including the parent in the constructor vs creating the new window without the parent reference. So 2ndWindow = new 2ndWindow(text, this); works, but
          2ndWindow = new 2ndWindow(text); causes the weird behavior above.

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

            Passing the parent as parameter makes you new window a child of its parent. Without it, it's a top level widget.

            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
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Just as a note.
              The QApplication has a setting that will auto close the app if all top level windows are closed.
              https://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop
              So i wondered if that what you saw when you closed 3rd window and window 2 also was closed.

              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