Put or dock 2 QMainWindow in other
-
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_MainQMainWindow2Question 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.
-
Hi,
Why do you have so many QMainWindow based widgets ?
-
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.
-
@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? -
That's really not clear. From the looks of it, you have a dialog modality issue.
-
@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 testRegrding to this post,
https://forum.qt.io/topic/39402/solved-qdockwidget-disable-always-on-top/14Coz detached QMainWindow1 from QMainWindow and minimized is "free" not like separated app what would be good in this case.
-
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.
-
Here is minimal example scheme what I prepared: dock 2 QMainWindow in other_.zip
https://easyupload.io/czrwotLooks like here:
What I need:
- Operate on MainWindow when MainWindow1 and MainWindow2 is opened
- Minimize MainWindow1 and MainWindow2 to windows10 taskabar to call when I need
- Minimize dockWidget_1 and dockWidget_2 after undock to windows10 taskabar to call when I need
- Dock MainWindow1 and MainWindow2 to dockWidget_3 and dockWidget_4
I not add a code to safe place for right solutions for this base functions.
-
Sorry, It got lost.
Your "operate" concept is not clear.
-
@Bamboleo said in Put or dock 2 QMainWindow in other:
Operate on MainWindow
-
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.
-
By this point 1 want minimize this to windows taskbar if is possible when using MainWIndow and restore MainWIndow2 when planing use this again
-
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.
-
And 4 point on image is about efforts and attempts to dock MainWIndow2 to dockWidgetContents_4 on right side of MDI.
-
-
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.