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.
Forum Updated to NodeBB v4.3 + New Features

Explicitly setting `DockWidgetFeature` properties disables those properties.

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 317 Views 2 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.
  • RokeJulianLockhartR Offline
    RokeJulianLockhartR Offline
    RokeJulianLockhart
    wrote on 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.

    Pl45m4P 1 Reply Last reply
    0
    • Pl45m4P Pl45m4

      @RokeJulianLockhart

      As mentioned above, OR them using binary OR operator:

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

      (not tested)

      RokeJulianLockhartR Offline
      RokeJulianLockhartR Offline
      RokeJulianLockhart
      wrote on 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
      • RokeJulianLockhartR RokeJulianLockhart
        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

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by Pl45m4
        #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
        • RokeJulianLockhartR Offline
          RokeJulianLockhartR Offline
          RokeJulianLockhart
          wrote on 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.

          Pl45m4P 1 Reply Last reply
          0
          • RokeJulianLockhartR RokeJulianLockhart

            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'

            Pl45m4P Online
            Pl45m4P Online
            Pl45m4
            wrote on 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

            RokeJulianLockhartR 1 Reply Last reply
            1
            • Pl45m4P Pl45m4

              @RokeJulianLockhart

              As mentioned above, OR them using binary OR operator:

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

              (not tested)

              RokeJulianLockhartR Offline
              RokeJulianLockhartR Offline
              RokeJulianLockhart
              wrote on 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
              • RokeJulianLockhartR RokeJulianLockhart has marked this topic as solved on

              • Login

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