Undesired padding in a right docked dockWidget
-
Hello!
My issue is: how to keep docked to the right a dockWidget with a MaximumWidth defined.
I'm working with PyQt5, with a QMainWindow with a mdiArea set as CentralWidget, and a dockWidget on the right side.Here is my code:
self.dockWidget = QDockWidget("Test") self.dockWidget.setFeatures(self.dockWidget.DockWidgetClosable) self.dockWidget.setAllowedAreas(Qt.RightDockWidgetArea) self.dockWidget.setMinimumWidth(250) self.dockWidget.setMaximumWidth(400) self.addDockWidget(Qt.RightDockWidgetArea, self.dockWidget)
My issue is: when I'm manually resizing the width of the dockWidget, at the maximums width the widget is no more enlarging, but it is still moving. It seems that it is not able to remain docked to the mainWindow, creating an undesired padding space (as you can see in the image below).
In case I put the dockWidget at the left side, I have no issue: at the maximum width the dockWidget is no more enlarging, and no padding is created.
Can you please help me to have the same behaviour docking the widget to the right?
Thank you in advance for your help!!
-
Hello.
I have not a layout. Is it this the issue?
I've tried to write a simple main.py code to run.
I have the same issue wiht undesired padding both on the left and on the right side:Here is the code. Thank you in advance for the help:
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
class MainWindow(QMainWindow):
def init(self):
super().init()
self.initUI()def initUI(self): self.setObjectName("MainWindow") self.move(400, 100) self.resize(1000, 600) # Central Widget - MdiArea self.mdiArea = QMdiArea() self.mdiArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.mdiArea.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.mdiArea.setViewMode(QMdiArea.TabbedView) self.mdiArea.setTabsClosable(True) self.mdiArea.setTabsMovable(True) self.mdiArea.setMinimumWidth(50) self.setCentralWidget(self.mdiArea) # List Widget on the left side self.listLeftSide = QListWidget() self.DocListLeft = QDockWidget("Test - Left Side") self.DocListLeft.setFeatures(self.DocListLeft.DockWidgetClosable) self.DocListLeft.setMinimumWidth(250) self.DocListLeft.setMaximumWidth(400) self.addDockWidget(Qt.LeftDockWidgetArea, self.DocListLeft) # Dock Widget on the right side self.dockWidget = QDockWidget("Test - Rigth Side") self.dockWidget.setFeatures(self.dockWidget.DockWidgetClosable) self.dockWidget.setAllowedAreas(Qt.RightDockWidgetArea) self.dockWidget.setMinimumWidth(250) self.dockWidget.setMaximumWidth(400) self.addDockWidget(Qt.RightDockWidgetArea, self.dockWidget)
if name == 'main':
app = QApplication(sys.argv)
wnd = MainWindow()
wnd.show()
sys.exit(app.exec_())