PDA

View Full Version : how to hide the title bar when a QDockWidget is docked?



oscar721
19th June 2008, 04:36
hello everyone,

I want to set the QDockWidget to hide it's title bar ( include the close button ) when it is docked and show its title bar while it is floating ( like the QDockWindow )

How can i do this ?

Thank you.

jpn
19th June 2008, 05:45
But how would you undock it? A dock widget without title loses most of its functionality nominal to dock widgets. A dock widget without title is called splitter... ;)

benacler
19th June 2008, 18:29
well, he may implement his own docking/undocking buttons elsewhere...
If you want to remove the title bar, you have to use setTitleBarWidget(0) but this will remove the title bar widget from the undocked widget too, so the best thing to do is writing your custom title bar widget and hiding / showing it depending on the status of the dockwidget.

hholtmann
21st September 2009, 20:20
I'm using Qt v4.3.2, and had the same problem and discovered that calling setTitleBarWidget(0) is NOT sufficient to remove the title bar and free up the client window space when the widget is DOCKED. This is because the class reverts to the internal default layout of reserving space for a title bar when the member is NULL(0).

However, the following simple trick will work:

// to hide the title bar completely must replace the default widget with a generic one
QWidget* titleWidget = new QWidget(this); /* where this a QMainWindow object */
dock->setTitleBarWidget( titleWidget );


My situation is simple thought since I never need to worry about undocking or moving the DocWidget during run-time; it is controlled by global app settings at startup and only needs to hold a static bitmap image for product branding.

I thought I should answer this thread question for completeness; since I was struggling with the same problem since i'm learning Qt and had to figure this one out on my own.

dachick
21st November 2010, 13:04
Hi,

I tried your trick with QtJambi but get the following warning all the time:


QWidget::setMinimumSize: (dockNavigate/QDockWidget) Negative sizes (0,-1) are not possible

whereby dockNavigate is one of my fields.

setting the size manually does not seem to help.

Any ideas on this?

ST MARTIN
23rd January 2014, 21:16
Hi,
The warning QWidget::setMinimumSize: (dockNavigate/QDockWidget) Negative sizes (0,-1) are not possible occur because some Widgets are extending over the boundaries of the QDockWidget.
I had the same warning, and all I did for clearing It was editing the frame with Design, making the QDockWidget large enough to cover all objects included.