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. Undesired padding in a right docked dockWidget
Forum Updated to NodeBB v4.3 + New Features

Undesired padding in a right docked dockWidget

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 336 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.
  • F Offline
    F Offline
    Foggyland
    wrote on last edited by
    #1

    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!!

    04e28d2e-1a62-4930-a540-a782f45e8d10-image.png

    Pl45m4P 1 Reply Last reply
    0
    • F Foggyland

      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!!

      04e28d2e-1a62-4930-a540-a782f45e8d10-image.png

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Foggyland

      Are you using layouts for your centralWidget and dockWidget?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Foggyland
        wrote on last edited by
        #3

        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:

        f2cab121-550c-4df3-abb2-0f3170db3fd9-image.png

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

        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