Donald Duck
Donald Duck

Reputation: 8892

Minimize button and context help button in the same title bar in 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?

Upvotes: 2

Views: 958

Answers (1)

Mike
Mike

Reputation: 8355

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.

Upvotes: 5

Related Questions