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?
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_CONTEXTHELPcannot be used with theWS_MAXIMIZEBOXorWS_MINIMIZEBOXstyles.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With