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. How can one have two or more active windows at the same time?

How can one have two or more active windows at the same time?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.3k 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.
  • B Offline
    B Offline
    bask185
    wrote on last edited by
    #1

    I have a small obstacle with my GUI application. I need to be able to use the pushbuttons of 2 separate windows at the same time.
    alt text
    alt text

    That bottem bar is my toolbar. It is a separate window which I can open from the mainwindow.

    Clicking on one of the toolbar's pushbuttons emits a signal to the mainwindow which opens one of the following windows; Help, maintenance, Details, SSP........ Database.

    When one of the 'new' windows is open, I cannot use the buttons of the toolbar anymore. The idea is that if I open lets say the 'Help' window and I click on the 'SSP' button on the toolbar, the 'Help' window closes and the 'SSP' window opens.

    Right now I have to manually close the 'new' window before I can use the Toolbar again. I have tried 2 ways of opening the windows but so far I have had no luck :/

    Way 1:

    help->setModal(true);
    help->setGeometry(0,0,1024,668);
    help->exec();
    

    Way 2:

    login = new Login(this);
    login->setGeometry(0,0,1024,668);
    login->exec();
    

    Way 1 has as drawback that only the last-launched window is active and thus useable

    Way 2 has more drawbacks. In case when I use it with the toolbar the signals become inactive so the pushbuttons don't do a thing. In case I use this way for any of the other windows, the toolbar becomes hidden as long as the other window is active. When I manually close the window the toolbar re-appears.

    I tried every combination but no luck.

    Which Magic Qt feature can make this obstacle go away?

    jsulmJ 1 Reply Last reply
    0
    • jsulmJ jsulm

      @bask185 said in How can one have two or more active windows at the same time?:

      help->setModal(true);
      help->setGeometry(0,0,1024,668);
      help->exec();

      You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html

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

      @jsulm said in How can one have two or more active windows at the same time?:

      @bask185 said in How can one have two or more active windows at the same time?:

      help->setModal(true);
      help->setGeometry(0,0,1024,668);
      help->exec();

      You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html

      This works ;)

      @SGaist said in How can one have two or more active windows at the same time?:

      Hi,

      What about using a QStackedWidget and switch between the widgets you want to show ?

      I'll read it for usage in the feature. For now Jsulms simple solution suffices.

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

        Hi,

        What about using a QStackedWidget and switch between the widgets you want to show ?

        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
        • B bask185

          I have a small obstacle with my GUI application. I need to be able to use the pushbuttons of 2 separate windows at the same time.
          alt text
          alt text

          That bottem bar is my toolbar. It is a separate window which I can open from the mainwindow.

          Clicking on one of the toolbar's pushbuttons emits a signal to the mainwindow which opens one of the following windows; Help, maintenance, Details, SSP........ Database.

          When one of the 'new' windows is open, I cannot use the buttons of the toolbar anymore. The idea is that if I open lets say the 'Help' window and I click on the 'SSP' button on the toolbar, the 'Help' window closes and the 'SSP' window opens.

          Right now I have to manually close the 'new' window before I can use the Toolbar again. I have tried 2 ways of opening the windows but so far I have had no luck :/

          Way 1:

          help->setModal(true);
          help->setGeometry(0,0,1024,668);
          help->exec();
          

          Way 2:

          login = new Login(this);
          login->setGeometry(0,0,1024,668);
          login->exec();
          

          Way 1 has as drawback that only the last-launched window is active and thus useable

          Way 2 has more drawbacks. In case when I use it with the toolbar the signals become inactive so the pushbuttons don't do a thing. In case I use this way for any of the other windows, the toolbar becomes hidden as long as the other window is active. When I manually close the window the toolbar re-appears.

          I tried every combination but no luck.

          Which Magic Qt feature can make this obstacle go away?

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

          @bask185 said in How can one have two or more active windows at the same time?:

          help->setModal(true);
          help->setGeometry(0,0,1024,668);
          help->exec();

          You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html

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

          B 1 Reply Last reply
          2
          • jsulmJ jsulm

            @bask185 said in How can one have two or more active windows at the same time?:

            help->setModal(true);
            help->setGeometry(0,0,1024,668);
            help->exec();

            You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html

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

            @jsulm said in How can one have two or more active windows at the same time?:

            @bask185 said in How can one have two or more active windows at the same time?:

            help->setModal(true);
            help->setGeometry(0,0,1024,668);
            help->exec();

            You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html

            This works ;)

            @SGaist said in How can one have two or more active windows at the same time?:

            Hi,

            What about using a QStackedWidget and switch between the widgets you want to show ?

            I'll read it for usage in the feature. For now Jsulms simple solution suffices.

            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