How can I add widgets to title bars in QMainWindow?

c++, qt, qt4

Solution

You cannot. What you can do is to create a completely custom window by hinting that you don't want a title bar using a Qt::WindowFlag. Notice - these flags are hints and not settings. Then you can create your own title bar and add whatever you like to it.

Also, notice, this will make your application harder to move between platforms. On the X11 side, you will even have to test against different window managers as they sometimes treat hints differently.

Problem

Is any posibility to add widgets in titlebar of QMainWindow? I try to avoid "emulate" a title bar by making a custom widget for that and hiding the default title bar (from Qt::WindowFlags). I am using QT 4.5 or 4.6 beta.

Original source