0

How can i manipulate this button [img 1], which automaticly created in my project?

Interested function:

  1. Delete;
  2. Open new window with help;

enter image description here

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
  • Your question is rather unclear. Could you provide a [MCVE], or at least describe the minimal steps to create a new application, which has that? – hyde Feb 06 '17 at 07:41
  • 2
    I _think_ this is a duplicate, but not completely sure http://stackoverflow.com/questions/81627/how-can-i-hide-delete-the-help-button-on-the-title-bar-of-a-qt-dialog – SingerOfTheFall Feb 06 '17 at 07:41
  • In case this is a duplicate of just that, see [`Qt::WindowContextHelpButtonHint` in Qt docs](http://doc.qt.io/qt-5/qt.html#WindowType-enum). – hyde Feb 06 '17 at 07:46
  • @SingerOfTheFall The question is not about hiding the button, but how to use it. – Benjamin T Feb 06 '17 at 11:40
  • @BenjaminT, maybe, but by "manipulating the button" (as the OP phrased it) I personally understand hiding/showing/moving the button/etc. Anyway, I'm not entirely sure and that's why I haven't closed this as a duplicate. – SingerOfTheFall Feb 06 '17 at 11:42
  • Actually there are two questions here and I guess it wouldn't be dumb to split them. The question "How can I hide ? ("What's this?") button in Qt?" could be marked as a [duplicate](http://stackoverflow.com/questions/81627/how-can-i-hide-delete-the-help-button-on-the-title-bar-of-a-qt-dialog), while the "How to override the "What's this?" button behavior in Qt" would get the answer "You can't" – cubuspl42 Feb 06 '17 at 15:56

2 Answers2

2

If you want to remove that button us the following in your dialog constructor:

setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

See QWidget::setWindowFlags() and Qt::WindowFlags in the documentation.

jpyams
  • 4,030
  • 9
  • 41
  • 66
Stormenet
  • 25,926
  • 9
  • 53
  • 65
0

The standard "?" button allows the user to enter a "What's this?" mode.

Quoting Qt documentation:

"What's This?" help is part of an application's online help system, and provides users with information about the functionality and usage of a particular widget. "What's This?" help texts are typically longer and more detailed than tooltips, but generally provide less information than that supplied by separate help windows.

If you want to simply show help, have a looke at QWidget::setWhatsThis(const QString &).

If you want to do more advanced things, have a look at the QWhatsThis class documentation. Basically you need to catch QEvent::WhatsThis events and implement the behavior you want.

On a side note, software behavior are standardized and users do not expect strange behaviors. You should not make your software behave in an unexpected way. Example: the "X" button in the title bar should close the window and/or close the application, it should not do anything else. This is called the principle of least astonishment

Benjamin T
  • 8,120
  • 20
  • 37