Results 1 to 9 of 9

Thread: QDockWidget

  1. #1
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QDockWidget

    QDockWidgets have a lot of cool things that they do! However, I need them to do more. I've searched but haven't found anything about hiding and showing or adding things to my titlebar.

    Okay so first the hide/show.....
    Right now I save the state of my mainwindow and then restore it. But this isn't the ideal way of doing things. Because I want to hide and show different dock widgets. I've tried to remove the widget and then add it later but that seems to mess QT up.
    Any ideas on how to do this right? I will even take a pointer to documentation on this!

    Second;
    Can you add icons to the title bar? they have the redoc icon and the close icon but I would like to add an icon that max's the window out!

    Thanks QT gurus!

  2. #2
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    DockWidgets have a method called:

    setHidden(bool);

    What I did was create a slot that called the setHidden method from a button's signal.
    This will toggle the dock window on and off.

  3. The following user says thank you to bitChanger for this useful post:

    fellobo (26th April 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    I beleive that you can set the QStyle of the DockWidget with some key enums like the following:

    QStyle::SP_TitleBarMaxButton

  5. #4
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget

    Well, this all sounds great and what I want. While the hide/show for the dock worked great I am having some trouble with the max button. I see how it works I am trying to get it implemented to the dock widget. If I can get something I will post it. Until then thanks gurus for the replies!

  6. #5
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    Since I found this problem interesting and I pay for support. I decided to ask Trolltech about this issue.

    They claim that there is no way to get a minimize or maxmize button in the title bar of a DockWidget.

    I'm sure you can simulate these actions with some QButtons, but title bar buttons are a no go ... for the current release anyway.

  7. The following user says thank you to bitChanger for this useful post:

    fellobo (28th April 2006)

  8. #6
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    I guess I got someone's attention at Trolltech on this issue for they sent me yet another email today. Here is the email I received:

    The problem with this is that the floating dock widget is a
    Tool window and Tool windows do not have minimize and maximize icons
    since that is not their nature. What you should do is call
    setWindowFlags() on the QDockWidget and specify that it should be a
    window type and not a tool type and this will then give it the
    appropriate titlebar. However this is not recommended as you could
    have problems with the QDockWidget functionality, you should instead
    put the widget in the QDockWidget into another widget that is top
    level. Then you won't have problems with the docking behaviour of the
    QDockWidget.

  9. #7
    Join Date
    Feb 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDockWidget

    So they want a widget that is a dockwidget that is my widget just to get a maximize button?

    Or are they saying that when they expand the dockwidget I grab it and remove the widget from the dockwidget and put it into a new widget? - NAH that won't work because then how will it now it can dock to the main window again.

    So does having a dockwidget within a widget go to the parent widget and give it docking capabilities?

    hmmmm?

  10. #8
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    Quote Originally Posted by bitChanger
    you should instead
    put the widget in the QDockWidget into another widget that is top
    level. Then you won't have problems with the docking behaviour of the
    QDockWidget.
    He?! I don't get this.

    I also tried add some buttons to a QDockWidget titlebar and if I remember right I managed to fake it
    Create a button (or any other widget) in the dock widget and use negative coordinates to move it to the titlebar. This is an ugly hack but it worked for me.
    IMHO the whole dock widget stuff is somehow closed up. It's nice if you use it like it is. But if you try to customize it...

  11. #9
    Join Date
    Jun 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget

    I followed the advice of using setWindowFlags() and it worked for me. I did not notice any incorrect behavior from the dockWidget. Looks like the trolltech people have fixed it. Thanks!


    Qt Code:
    1. // connect dockWidget's topLevelChanged signal, which is emitted when its floating property changes, to a user-defined slot
    2. connect(ui.dockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(dockWidget_topLevelChanged(bool)));
    3.  
    4.  
    5.  
    6. // when the floating property of dockWidget is changed from docked to floating
    7. // we make it a top level window (with minmize, maximize, and close button in the title bar)
    8. // by calling setWindowFlags(Qt::Window)
    9. // The dockWidget will automatically regain it's Qt::widget flag when it becomes docked again (by dragging it to the right place or double clicking the title bar)
    10. void CMainWindow::dockWidget_topLevelChanged(bool isFloating)
    11. {
    12. if(isFloating)
    13. { ui.dockWidget->setWindowFlags(Qt::Window);
    14. // setWindowFlags calls setParent() when changing the flags for a window, causing the widget to be hidden.
    15. // You must call show() to make the widget visible again
    16. ui.dockWidget->show();
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDockWidget magically disapear
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 11:44
  2. QDockWidget closing detection
    By danielperaza in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2008, 15:28
  3. contextmenu in QDockWidget title
    By klipko in forum Newbie
    Replies: 4
    Last Post: 7th March 2008, 22:32
  4. Replies: 8
    Last Post: 4th February 2007, 00:42
  5. QDockWidget flicker
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2006, 20:42

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
  •  
Qt is a trademark of The Qt Company.