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. PyQt QDockWidget in a Layout is no more movable ...
Forum Updated to NodeBB v4.3 + New Features

PyQt QDockWidget in a Layout is no more movable ...

Scheduled Pinned Locked Moved General and Desktop
qdockwidget
6 Posts 2 Posters 4.9k 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.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by Goffer
    #1

    Hi guys !

    I m new to Qt and I am dealing with my first UI.
    What I want to do is to have QDockWidgets into a ScrollArea and this scroll area is part of a QtabWidget so when I switch to tab2 I don't see my QDocksWidgets anymore ...

    After typing few lines of code :
    my QDockWidgets are going inside my QScrollArea I can dock them out and dock them back in but I can't move them when they are docked out...
    I have had a look at some "dockWidgetFeatures" tried the "isFloating" but nothing seems to work ...

    That's why I am writing this post, hopefully someone already dealt with that and can help me or just tell me that I am doing it the wrong way ...

    here is a part of my code:

    # create dock 
    self.dock = QtGui.QDockWidget(self.selectedFunction, parent=self)
    
    # edit features
    self.dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures)
    self.setDockOptions(QtGui.QMainWindow.AllowNestedDocks)
    
    # populate dock
    self.dockWidgetContent = QtGui.QWidget()
    self.dockLayout = QtGui.QVBoxLayout(self.dockWidgetContent)
    
    # add dock into a layout
    hbox = QtGui.QHBoxLayout()
    hbox.addWidget(self.dock)
    
    # add the layout into my scroll area  (ultraLayout is the general Layout inside my scroll)
    self.ultraLayout.insertLayout(-1, hbox)
    
    # set dock content 
    self.dock.setWidget(self.dockWidgetContent)
    

    Thank you !
    Goffer

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should put your dock widgets in the available QMainWindow's dock area. Putting it in a layout like you do makes it treated as a normal widget.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • GofferG Offline
        GofferG Offline
        Goffer
        wrote on last edited by
        #3

        Hi SGait !

        I know that it might affect is behavior but the thing with the normal "dock area position" is that it doesn't do what I want.

        If I switch tab, I will still have my docks visible as it is not part of the tab (in centralWidget) but part of the dockArea which is all around the centralWidget.
        And further more, I m not even sure that by using the dockArea , I could have a scroll bar.

        So, There is no way to make the out docked dockWidget movable ? except if I put it in a new widgetWindow (but I don't want to do that)?
        If i have to go for the new widgetWindow, then I prefer not to use the QDockWidget anymore as it becomes useless and simply do layouts that will be parented under my scrollArea or a new widgetWindow.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You could have several QMainWindow in your stack as central widget if it's really what you need.

          Out of curiosity, why do you need all these QDockWidget that changes for every tab ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • GofferG Offline
            GofferG Offline
            Goffer
            wrote on last edited by
            #5

            I only want my dock area to be in the first tab. That's all.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you can use a QMainWindow as widget in the first tab so you have everything you need in it and don't need to fiddle around to replicate the functionality

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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