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. Weird resizing of QDockWidget in QMdiArea subwindows

Weird resizing of QDockWidget in QMdiArea subwindows

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 558 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.
  • J Offline
    J Offline
    jsleroy
    wrote on last edited by jsleroy
    #1

    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,
    JS

    import 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_())
    
    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