How to change QDockWidget dock area in code?



  • 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.


  • Moderators

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


  • Lifetime Qt Champion

    Hi,

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



  • @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.



  • @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.