Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimize button and context help button in the same title bar in Qt

Tags:

c++

qt

To make a help button in the title bar in a Qt window of the type QWidget, I do like this:

myWindow->setWindowFlags(Qt::WindowContextHelpButtonHint);

This works fine.

To make a minimize button in the title bar in the same kind of window, I do like this:

myWindow->setWindowFlags(Qt::WindowMinimizeButtonHint);

This also works fine.

What I want to do is to have both a help button and a minimize button in the title bar of same window. For that, I tried to combine the flags:

myWindow->setWindowFlags(Qt::WindowContextHelpButtonHint | Qt::WindowMinimizeButtonHint);

This only shows the minimize button, not the help button (at least in Windows). How do I show both buttons in the same title bar?

like image 254
Donald Duck Avatar asked Dec 21 '25 16:12

Donald Duck


1 Answers

Unfortunately, this is impossible on windows. Here is why:

  • Qt::WindowMinimizeButtonHint is implemented by adding WS_MINIMIZEBOX window style, see here.
  • Qt::WindowContextHelpButtonHint is implemented by adding WS_EX_CONTEXTHELP extended window style, see here.

From the reference for WS_EX_CONTEXTHELP:

WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.

So, you can never have a window with the minimize button [ - ] and the context help button [ ? ] on windows.

If you really want to do so, you may have to use a frameless window, and provide your own custom frames.

Note: This answer is about windows platform only.

like image 89
Mike Avatar answered Dec 24 '25 05:12

Mike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!