How to show title bar on docked QDockWidget?



  • I have a QDockWidget that, instead of docking, it completely closes when pressing the close button. Is there a way to still see the title bar when the widget is docked?

    Apparently it should be like that by default. Looking around for an answer I see that other people want to HIDE the title bar when docked, but I want it to be visible because now it isn't.

    The widget is set to be closable, not movable, not floatable and with a vertical titlebar.


  • Moderators

    did you set the title with QWidget::setWindowTitle()?



  • No, I added it with QtCreator. Should I code it?


  • Moderators

    as long as you've set the windowTitle property you should be fine.
    If you did it seems like a bug in Qt. Can you test it on another system?



  • I'm not sure I was using it properly. Should the close button (X) close or dock the window?

    I may try it with linux, but it will take a while because I'd have to install Qt.


  • Moderators

    close it



  • and how may I dock it? I can drag to expand and shrink the dock, but haven't found a way to dock it with one click. Can it be done?


  • Moderators

    -AFAIK this isn't possible.-
    Only a button in docked state is displayed to make it floating. But not the other way around.
    I think this has to do with the fact, that it's not clear where to put once it is floating. Because if you have many QDockWidgets the dock area's arrangement can have changed a lot in the meantime.

    Edit: double clicking on the title-bar redocks the window



  • mmm... hold on, I think I got something wrong here. English is not my first language... I just realized I missunderstood what "dockable" means. Sorry about that. Now I do know what it means, and I see I wasn't using the right word.

    What I need is a widget that behaves similarly to a QToolBox, but I need the tabs to be side by side, not one on top of the other, and different tabs may be open at the same time. As far as I can tell, QToolBox can't be tweaked that much (it was my first choice).

    I thought that I could do it with QDockWidgets set side by side. Is that how I should do it or am I completely out of track?


  • Moderators

    There is no such widgets that comes with Qt which does what you want.
    You will have to do it by your own i'm afraid.

    Or you do it with the widgets you already know but with some losings of functionality.



  • Ok, thanks a lot!


  • Moderators

    actually you can give the QDockWidget approach another try.
    You can use
    @
    dockWidget->setFeatures( QDockWidget::DockWidgetVerticalTitleBar );
    @
    Maybe this is already what you want?



  • Thanks.

    I already took a look at that. It's nice, but I can't put dock widgets side by side.

    Actually what I'm looking for is collapsible widgets that can be set side by side and that they show the vertical title bar when collapsed.



  • I have been trying to create a collapsible dock widget, subclassing QDockWidget. I got as far as creating a clickable vertical title bar. But the key to success is being able to resize the dock widget to the title bar's width. I've been searching around, and it seems impossible to do. As far as I'm concerned, dock widgets cannot be resized. They adjust to their contents.

    If their's a way to override this, it would be great. But I think I'll have to code a collapsible panel from scratch.

    I'll start a new thread because I think this one would mislead others seeking the same.


  • Moderators

    and what happens when you "collapse" the widget by just hiding the widget inside the QDockWidget?
    So you would need to listen to the double click event on the title bar widget and toggle the visibility of the content widget.



  • hey! It works! Thank you very much!

    There are some issues with the height, which is affected as well, but I'm sure it's pretty easy to solve. I'll work on it and let you know my progressions.



  • I haven't managed to solve the height issue.

    When I hide the widget inside the QDockWidget, it collapses in all directions, not just horizontally. So the widget resizes to the bar's minimum size, which is the minimum size of a button (I replaced the title bar widget with this great "OrientationButton":http://www.qtcentre.org/wiki/index.php?title=OrientationButton).

    How would you prevent it from collapsing veritcal-wise? If I set minimumHeight() to anything big, then it behaves awkwardly when the height of the window containing the QDockWidget is shrunk (if it can be shrunk at all).



  • I just discovered QSplitter. Maybe that's what I'm looking for.


Log in to reply
 

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