PDA

View Full Version : How can I add a custom button to a QWidget's title bar



JPNaude
28th January 2009, 09:43
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

seneca
28th January 2009, 09:53
Afaik this is only possible for QDockWidget, using the setTitleBarWidget method.

wysota
28th January 2009, 09:55
I don't think you can do it without reimplementing QMdiSubWindow internals (handling paintEvent and mouse{Press,Release}Event at least).

JPNaude
28th January 2009, 10:11
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

freelucas
22nd February 2010, 10:40
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!