Results 1 to 6 of 6

Thread: how to hide the title bar when a QDockWidget is docked?

  1. #1

    Default how to hide the title bar when a QDockWidget is docked?

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to hide the title bar when a QDockWidget is docked?

    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...
    J-P Nurmi

  3. #3
    Join Date
    Dec 2007
    Posts
    14
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to hide the title bar when a QDockWidget is docked?

    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.

  4. #4
    Join Date
    Sep 2009
    Posts
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: how to hide the title bar when a QDockWidget is docked?

    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.

  5. The following 2 users say thank you to hholtmann for this useful post:

    Kryzon (30th December 2014), mclark (8th April 2010)

  6. #5
    Join Date
    Nov 2010
    Posts
    9
    Thanks
    1

    Default Re: how to hide the title bar when a QDockWidget is docked?

    Hi,

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

    Qt Code:
    1. QWidget::setMinimumSize: (dockNavigate/QDockWidget) Negative sizes (0,-1) are not possible
    To copy to clipboard, switch view to plain text mode 

    whereby dockNavigate is one of my fields.

    setting the size manually does not seem to help.

    Any ideas on this?

  7. #6
    Join Date
    Jan 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to hide the title bar when a QDockWidget is docked?

    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.

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 22:24
  2. contextmenu in QDockWidget title
    By klipko in forum Newbie
    Replies: 4
    Last Post: 7th March 2008, 22:32
  3. No restore button in QDockWidget title bar
    By trskel in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2007, 09:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.