Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Put or dock 2 QMainWindow in other
QtWS25 Last Chance

Put or dock 2 QMainWindow in other

Scheduled Pinned Locked Moved Unsolved Qt for Python
13 Posts 2 Posters 1.0k 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
    Bamboleo
    wrote on last edited by
    #1

    Hi,
    I not used QT and Pyside2 long time, and I stuck with some idea.

    I have MVC app and

    class MainView(QMainWindow):

    This class calling 2 QMainWindow and 2 QDialog, and other by some btns.

    Have this import
    from PySide2.QtWidgets import QMainWindow,QDialog,QMdiArea
    from View.QMainWindow1 import Ui_MainWindow as Ui_MainQMainWindow1
    from View.QMainWindow2 import Ui_MainWindow as Ui_MainQMainWindow2

    Question is: how to put these 2 QMainWindow and 2 QDialog to some places like centralwidget or horizontalLayout?

    It's should be something like this?
    self.ui.centralwidget(Ui_MainQMainWindow1)
    self.ui.centralwidget(Ui_MainQMainWindow2)

    Or should combine this by Super?
    def init(self, parent=None):
    QtWidgets.QMainWindow.init(self, parent)
    self.ui = Ui_MainChat()

    If this is possible, the whats happening with menu, statusbars, toolbars if exist separately for these 2 QMainWindow1 and QMainWindow2?

    It's problable bether to implemnt in docWidget, but due that this not have a menu, statusbars, toolbars was worst, but now other dilema come.

    Other sugestion can be usefull how to join toolbars, statusbars to dockQidget.

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

      Hi,

      Why do you have so many QMainWindow based widgets ?

      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 Offline
        B Offline
        Bamboleo
        wrote on last edited by
        #3

        Coz QMainWindows was as separated apps or modules in other and want join these windows to one app an pack this as some bundle.

        I using Pyside2 and have6.

        The main question is that I can do this formaly?

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

          It would likely be cleaner to extract the interesting parts of these apps to build your interface rather than trying to just cram them together.

          That said one possible way could be to use a QStackedWidget to switch between them.

          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
          2
          • B Offline
            B Offline
            Bamboleo
            wrote on last edited by
            #5

            @SGaist thx for suggestion I'll try to test this.

            Once question around.
            If this QtWidgets as QMainWindow1/2 and QDialog are opened from btns on top of main QMainWindow as base app, then this main QMainWindow is impossible to operate and just QMainWindow1/2 and QDialog reacting around GUI (eg. moving on desktop, operate btns on dialogs, etc.). How to prevent this situation and activate main QMainWindow if other are in top?

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

              That's really not clear. From the looks of it, you have a dialog modality issue.

              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 Offline
                B Offline
                Bamboleo
                wrote on last edited by Bamboleo
                #7

                @SGaist said in Put or dock 2 QMainWindow in other:

                dialog modality issue

                Not sure it is modality issue. If i clickiking QMainWindow1 or QMainWindow2 or QDialog the these are on top.
                But when QMainWindow is clicked then no reaction.

                It's need something like self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) for QMainWindow when clicked but without some combination around checking it was clicked. Or it's necesary always?!

                I try something like this but not helping any way:
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)
                self.modal = QMainWindow(self)
                self.modal.setWindowModality(QtCore.Qt.WindowModal)
                self.modal.setWindowModality(QtCore.Qt.NonMod) #as other test

                Regrding to this post,
                https://forum.qt.io/topic/39402/solved-qdockwidget-disable-always-on-top/14

                Coz detached QMainWindow1 from QMainWindow and minimized is "free" not like separated app what would be good in this case.
                QT_window_minimized.png

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

                  Please provide a minimal compilable example that shows the issue.

                  Note that as I already suggested, you should properly design your new application rather than trying to slap together these multiple different QMainWindow based interfaces.

                  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
                  2
                  • B Offline
                    B Offline
                    Bamboleo
                    wrote on last edited by Bamboleo
                    #9

                    Here is minimal example scheme what I prepared: dock 2 QMainWindow in other_.zip
                    https://easyupload.io/czrwot

                    Looks like here:
                    QT_for operate on docks.png

                    What I need:

                    1. Operate on MainWindow when MainWindow1 and MainWindow2 is opened
                    2. Minimize MainWindow1 and MainWindow2 to windows10 taskabar to call when I need
                    3. Minimize dockWidget_1 and dockWidget_2 after undock to windows10 taskabar to call when I need
                    4. Dock MainWindow1 and MainWindow2 to dockWidget_3 and dockWidget_4

                    QT_windows.png

                    I not add a code to safe place for right solutions for this base functions.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      Bamboleo
                      wrote on last edited by
                      #10

                      @SGaist any attention here?

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

                        Sorry, It got lost.

                        Your "operate" concept is not clear.

                        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
                        0
                        • B Offline
                          B Offline
                          Bamboleo
                          wrote on last edited by Bamboleo
                          #12

                          @Bamboleo said in Put or dock 2 QMainWindow in other:

                          Operate on MainWindow

                          1. When you runing this minimal example, the app opening Dialog and MainWIndow2 - in this case I can't click and operate ond MainWIndow to give option to swith betwen MainWIndow and MainWIndow2 or any dialog.

                          2. By this point 1 want minimize this to windows taskbar if is possible when using MainWIndow and restore MainWIndow2 when planing use this again

                          3. This same like 2. want minimize docsk to windows taskbar if is possible to easy manage windows, specialy if I have many MainWIndow or docks. I using advanced GUI with many tabed docks, but need more space for them and often need undock to maximize or other. Then to have comfy workspace I must dock back, but can be good to minimize to W10 taskbar.

                          4. And 4 point on image is about efforts and attempts to dock MainWIndow2 to dockWidgetContents_4 on right side of MDI.

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

                            If you cannot access an underlying windows when a dialog is present it usually means that this dialog is modal to the widget that is now not accessible anymore.

                            If you have that many dock widgets and it is a problem, you may want to consider taking the time to re-architect your GUI. Requiring 250 dock widgets to be visible at the same time is usually not a good sign.

                            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
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved