Results 1 to 5 of 5

Thread: How can I add a custom button to a QWidget's title bar

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default How can I add a custom button to a QWidget's title bar

    Hi

    I know this should be possible but after searching for an answer I am still without one. Basically, I have a QMdiArea with a bunch of windows in it. I want to add a custom button (next to the minimize, maximize and close buttons) in the title bar of QMdiSubWindow that allows the user to release the window from the QMdiArea so that it can be shown as a normal widget (almost like undocking a dock widget). When the user click on the buttom again, it should be docked inside the QMdiArea again. I can think of ways to take care of releasing and docking the window. I just want to add a button to the title bar.

    I've looked at Qt::WindowFlags but I didn't see anything that looks like what I need.

    How can I do this?

    Thanks for any inputs.
    Jaco

  2. #2
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I add a custom button to a QWidget's title bar

    Afaik this is only possible for QDockWidget, using the setTitleBarWidget method.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I add a custom button to a QWidget's title bar

    I don't think you can do it without reimplementing QMdiSubWindow internals (handling paintEvent and mouse{Press,Release}Event at least).

  4. #4
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: How can I add a custom button to a QWidget's title bar

    Hi

    Thanks for the responses. Seems like the easiest way to go forward would be to add a context menu giving the user the same option/functionality.

    Too bad its not possible (easily)

    Thanks again,
    Jaco

  5. #5
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4

    Default Re: How can I add a custom button to a QWidget's title bar

    Dear JPNaude:
    I am very interested in your idea about how to dock the QMdiSubWindow.
    Could you please tell me more details?
    Thanks a lot!

Similar Threads

  1. Creating Custom Ellipse Button
    By VireX in forum Qt Programming
    Replies: 18
    Last Post: 30th May 2012, 12:23
  2. Replies: 5
    Last Post: 21st April 2008, 08:54
  3. Window title bar and "X" button
    By markcole in forum Qt Programming
    Replies: 3
    Last Post: 20th December 2007, 21:58
  4. No restore button in QDockWidget title bar
    By trskel in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2007, 10: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.