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. How to change QDockWidget dock area in code?
Forum Updated to NodeBB v4.3 + New Features

How to change QDockWidget dock area in code?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.9k Views 3 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.
  • HarbH Offline
    HarbH Offline
    Harb
    wrote on last edited by
    #1

    Hi!

    I have several QDockWidgets in my QMainWindow. I want to make an Action, which will set all DockWidgets to there default places. Can't find suitable method for that. Tried to use QMainWindos::addDockWidget(Qt::DockWidgetArea area, QDockWidget * dockwidget). But it doesn't work. Ofcourse I can use QWidget::SetGeometry(), but it will not help me to "dock" my DockWidgets.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      "Doesn't work" is rather general ;) Can you explain what you want to achieve and possibly provide a code sample of what you tried?

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

        Hi,

        Did you remove the QDockWidget before adding it again to your QMainWindow ?

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

        HarbH 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Did you remove the QDockWidget before adding it again to your QMainWindow ?

          HarbH Offline
          HarbH Offline
          Harb
          wrote on last edited by
          #4

          @SGaist Hi!

          In fact i finally figured out, how does it work. Now it works properly, after I set QDockWidget::setFloating(false), before addDockWidget method. But I still struggle with thous weird behavior of QDockWidget, when it docked. I can't set the size of the DockWidget properly when it is in "docked" state. It is strange, that there are no explicit methods which give you full control of DockWidges.

          1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            "Doesn't work" is rather general ;) Can you explain what you want to achieve and possibly provide a code sample of what you tried?

            HarbH Offline
            HarbH Offline
            Harb
            wrote on last edited by
            #5

            @Chris-Kawa I want to move DockWidget from its actual place to default place and set default geometry. Which is determined by some global constants for example. I tried to use addDockWidget but nothing happened(it didn't change its geometry) course it seems you have to set "float" property TRUE initially. Finally I got it, just experimenting with different methods. BUT, as I said in previous post I can't understand how does DockWidgets behave when they are in "docked" state. For example how does Qt manage to save all geometry of all DockWidgets and then restore it properly with SaveState and RestoreState? I want to do that manually.

            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