Weird resizing of QDockWidget in QMdiArea subwindows
-
Hi,
First, I'm new to Qt, so sorry if that question has already been answered (although I've not found anything helpful for the moment looking in the forum/google/StackOverflow).
I have an application consisting of a main window containing a mdi area. Each mdi subwindow are the same (same class) composed of a central widget and two docked widgets. Let's say I have two documents displayed and tabified (might be important). If I resize the docked widgets in the first document, then move to the second one, and come back to the first one, the docked widget has been resized. I would have expected the docked widget to keep the same sizes. Note that I've just switch tabs, not resize anything.
I paste a small reproducer of this behaviour below.
This use PyQt & Qt 5.9.1 on Ubuntu 18.04.
I've tried a few different things, like changing layout or size policy but without success.
While trying to understand what's going on, I've noticed that a resize event is called on widgets when switching tab, which looks like this trigger the resizing of the docked widgets to a different size than the previous one.
Thanks for your help,
JSimport sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Subwindow(QMainWindow): def __init__(self, parent = None): super(Subwindow, self).__init__(parent) def widget(): w = QListWidget() w.addItem("item1") w.addItem("item2") w.addItem("item3") dw = QDockWidget(self) dw.setWidget(w) dw.setFloating(False) self.addDockWidget(Qt.RightDockWidgetArea, dw) widget() widget() w = QTextEdit() self.setCentralWidget(w) self.show() class MainWindow(QMainWindow): def __init__(self, parent = None): super(MainWindow, self).__init__(parent) self.mdi = QMdiArea() self.setCentralWidget(self.mdi) def window(): w = Subwindow(self) self.mdi.addSubWindow(w) window() window() self.mdi.setViewMode(QMdiArea.TabbedView) self.show() app = QApplication(sys.argv) ex = MainWindow() sys.exit(app.exec_())