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. Explicitly setting `DockWidgetFeature` properties disables those properties.

Explicitly setting `DockWidgetFeature` properties disables those properties.

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 174 Views
  • 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.
  • R Offline
    R Offline
    RokeJulianLockhart
    wrote on 9 Feb 2025, 19:09 last edited by
    #1
    toolbar_dock = PyQt6.QtWidgets.QDockWidget()
    toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable)
    toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable)
    toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
    toolbar_dock.setWindowTitle("Actions")
    

    To my knowledge, explicitly setting the DockWidgetFeatures should grant the QDockWidget them. However, that example produces:

    c3c7b67d-c5ad-4e2b-a823-78a2c91d35bb-Screenshot_20250209_190756.png

    ...whereas the undermentioned code:

    toolbar_dock = PyQt6.QtWidgets.QDockWidget()
    toolbar_dock.setWindowTitle("Actions")
    

    ...produces:

    d509c7f4-3380-4953-9c94-fbf15381cd0c-Screenshot_20250209_190842.png

    When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

    P 1 Reply Last reply 9 Feb 2025, 19:16
    0
    • P Pl45m4
      9 Feb 2025, 23:13

      @RokeJulianLockhart

      As mentioned above, OR them using binary OR operator:

      dock_widget.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
      

      (not tested)

      R Offline
      R Offline
      RokeJulianLockhart
      wrote on 9 Feb 2025, 23:51 last edited by
      #5

      @Pl45m4, thanks. That works:

      #!/usr/bin/env python3.13
      main_content_dock.setFeatures(
          PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable  | \
          PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable | \
          PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable
      )
      

      When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

      1 Reply Last reply
      0
      • R RokeJulianLockhart
        9 Feb 2025, 19:09
        toolbar_dock = PyQt6.QtWidgets.QDockWidget()
        toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable)
        toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable)
        toolbar_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
        toolbar_dock.setWindowTitle("Actions")
        

        To my knowledge, explicitly setting the DockWidgetFeatures should grant the QDockWidget them. However, that example produces:

        c3c7b67d-c5ad-4e2b-a823-78a2c91d35bb-Screenshot_20250209_190756.png

        ...whereas the undermentioned code:

        toolbar_dock = PyQt6.QtWidgets.QDockWidget()
        toolbar_dock.setWindowTitle("Actions")
        

        ...produces:

        d509c7f4-3380-4953-9c94-fbf15381cd0c-Screenshot_20250209_190842.png

        P Online
        P Online
        Pl45m4
        wrote on 9 Feb 2025, 19:16 last edited by Pl45m4 2 Sept 2025, 19:17
        #2

        @RokeJulianLockhart

        QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures), for both the C++ and the Qt Py wrappers, sets the given features... but just the recent ones you pass with the function (overriding everything else that was set before).
        Meaning if you setFeatures(DockWidgetFloatable) last like you do in your first example, this flag is the only one that is set, while the default config includes an OR'ed combination of floatable, closable and movable.

        So set all the preferred flags in one step.


        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
        2
        • R Offline
          R Offline
          RokeJulianLockhart
          wrote on 9 Feb 2025, 19:44 last edited by
          #3

          So set all the preferred flags in one step.

          @Pl45m4, embarrassingly, how do I do that for this method? I ask because:

          1. main_content_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable).setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable).setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
            

            setFeatures(self, features: QDockWidget.DockWidgetFeature): too many arguments

          2. main_content_dock.setFeatures([PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable, PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable, PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable])
            

            setFeatures(self, features: QDockWidget.DockWidgetFeature): argument 1 has unexpected type 'list'

          When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

          P 1 Reply Last reply 9 Feb 2025, 23:13
          0
          • R RokeJulianLockhart
            9 Feb 2025, 19:44

            So set all the preferred flags in one step.

            @Pl45m4, embarrassingly, how do I do that for this method? I ask because:

            1. main_content_dock.setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable).setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable).setFeatures(PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
              

              setFeatures(self, features: QDockWidget.DockWidgetFeature): too many arguments

            2. main_content_dock.setFeatures([PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable, PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable, PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable])
              

              setFeatures(self, features: QDockWidget.DockWidgetFeature): argument 1 has unexpected type 'list'

            P Online
            P Online
            Pl45m4
            wrote on 9 Feb 2025, 23:13 last edited by
            #4

            @RokeJulianLockhart

            As mentioned above, OR them using binary OR operator:

            dock_widget.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
            

            (not tested)


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

            ~E. W. Dijkstra

            R 1 Reply Last reply 9 Feb 2025, 23:51
            1
            • P Pl45m4
              9 Feb 2025, 23:13

              @RokeJulianLockhart

              As mentioned above, OR them using binary OR operator:

              dock_widget.setFeatures(QDockWidget.DockWidgetClosable | QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
              

              (not tested)

              R Offline
              R Offline
              RokeJulianLockhart
              wrote on 9 Feb 2025, 23:51 last edited by
              #5

              @Pl45m4, thanks. That works:

              #!/usr/bin/env python3.13
              main_content_dock.setFeatures(
                  PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable  | \
                  PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable | \
                  PyQt6.QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable
              )
              

              When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

              1 Reply Last reply
              0
              • R RokeJulianLockhart has marked this topic as solved on 9 Feb 2025, 23:51

              3/5

              9 Feb 2025, 19:44

              • Login

              • Login or register to search.
              3 out of 5
              • First post
                3/5
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved