QDockWidget - resizing it over other widget without changing size of that widget



  • Hi,
    I have question about QDockWidget.
    If there is a possibility that QDockWidget could be resized over other widget. I mean that now when I resize dockWidget (for example increase height of it) that docked widget change size of other widget that is a central widget. I want that docked widget will resize but over that central widget (without changing size of central widget). Is there possibility to do that? I thought I saw that solution somewhere but now I can't find it or I mistook it with some other widget.


  • Moderators

    No, QDockWidget can't do that. You would have to implement that yourself.
    The closest thing a QDockWidget can do is become a floating window, but I'm not sure that's what you mean.

    It's easy to do, but this type of thing doesn't play well with Qt layout system. Such widget would have to be put over other widgets without any layout applied and its size would have to be manually adjusted on resizeEvent of the parent.



  • So, maybe you could explain me one thing. I have dockWidget and central widget. In central widget I have QWidget container with two other widgets (one over other). First widget is used as a background, and second widget is over that first. That first widget is resizing when I resize dockWidget, but second widget not. Why does it happen?


  • Moderators

    It depends on how are these two widgets laid out. I'm guessing you set the first widget with setCentralWidget(). This puts it into the built in QMainWindow layout so it gets properly resized when needed. If the second one covers the first one then I'm guessing you just created it with a parent but did not put it into any specific layout.
    So you need to either manually adjust what's needed in that second widget or put it into a layout.


Log in to reply
 

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