<p>I am using Qt Dialogs in one of my application.
I need to hide/delete the help button. But i am not able to locate where exactly I get the handle to his help button. Not sure if its a particular flag on the Qt window.</p>

[{'answer_id': 81927, 'author': 'amos', 'author_id': 15429, 'author_profile': 'https://Stackoverflow.com/users/15429', 'pm_score': 7, 'selected': True, 'text': '<p>By default the <em>Qt::WindowContextHelpButtonHint</em> flag is added to dialogs.\nYou can control this with the <em>WindowFlags</em> parameter to the dialog constructor.  </p>\n\n<p>For instance you can specify only the <em>TitleHint</em> and <em>SystemMenu</em> flags by doing:</p>\n\n<pre><code>QDialog *d = new QDialog(0, Qt::WindowSystemMenuHint | Qt::WindowTitleHint);\nd-&gt;exec();\n</code></pre>\n\n<p>If you add the <em>Qt::WindowContextHelpButtonHint</em> flag you will get the help button back.</p>\n\n<p>In PyQt you can do:</p>\n\n<pre><code>from PyQt4 import QtGui, QtCore\napp = QtGui.QApplication([])\nd = QtGui.QDialog(None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)\nd.exec_()\n</code></pre>\n\n<p>More details on window flags can be found on the <a href="https://doc.qt.io/qt-5.7/qt.html#WindowType-enum" rel="noreferrer">WindowType enum</a> in the Qt documentation.</p>\n'}, {'answer_id': 82303, 'author': 'AMM', 'author_id': 11212, 'author_profile': 'https://Stackoverflow.com/users/11212', 'pm_score': 5, 'selected': False, 'text': '<p>Ok , I found a way to do this.</p>\n\n<p>It does deal with the Window flags. So here is the code i used:</p>\n\n<pre><code>Qt::WindowFlags flags = windowFlags()\n\nQt::WindowFlags helpFlag =\nQt::WindowContextHelpButtonHint;\n\nflags = flags &amp; (~helpFlag);   \nsetWindowFlags(flags);\n</code></pre>\n\n<p>But by doing this sometimes the icon of the dialog gets reset. So to make sure the icon of the dialog does not change you can add two lines.</p>\n\n<pre><code>QIcon icon = windowIcon();\n\nQt::WindowFlags flags = windowFlags();\n\nQt::WindowFlags helpFlag =\nQt::WindowContextHelpButtonHint;\n\nflags = flags &amp; (~helpFlag);   \n\nsetWindowFlags(flags);\n\nsetWindowIcon(icon);\n</code></pre>\n'}, {'answer_id': 358270, 'author': 'Michael Bishop', 'author_id': 45114, 'author_profile': 'https://Stackoverflow.com/users/45114', 'pm_score': 2, 'selected': False, 'text': "<p>The answers listed here will work, but to answer it yourself, I'd recommend you run the example program <code>$QTDIR/examples/widgets/windowflags</code>. That will allow you to test all the configurations of window flags and their effects. Very useful for figuring out squirrelly  windowflags problems.</p>\n"}, {'answer_id': 3817398, 'author': 'brandoneggar', 'author_id': 461134, 'author_profile': 'https://Stackoverflow.com/users/461134', 'pm_score': 0, 'selected': False, 'text': "<p>I couldn't find a slot but you can override the virtual <code>winEvent</code> function.</p>\n\n<pre><code>#if defined(Q_WS_WIN)\nbool MyWizard::winEvent(MSG * msg, long * result)\n{\n    switch (msg-&gt;message)\n    {\n    case WM_NCLBUTTONDOWN:\n        if (msg-&gt;wParam == HTHELP)\n        {\n\n        }\n        break;\n    default:\n        break;\n    }\n    return QWizard::winEvent(msg, result);\n}\n#endif\n</code></pre>\n"}, {'answer_id': 22039439, 'author': 'rrwick', 'author_id': 2438989, 'author_profile': 'https://Stackoverflow.com/users/2438989', 'pm_score': 4, 'selected': False, 'text': '<p>I ran into this issue in Windows 7, Qt 5.2, and the flags combination that worked best for me was this:</p>\n\n<p><strong>Qt::WindowTitleHint | Qt::WindowCloseButtonHint</strong></p>\n\n<p>This gives me a working close button but no question mark help button.  Using just Qt::WindowTitleHint or Qt::WindowSystemMenuHint got rid of the help button, but it also disabled the close button.</p>\n\n<p>As Michael Bishop suggested, it was playing with the windowflags example that led me to this combination.  Thanks!</p>\n'}, {'answer_id': 30934930, 'author': 'Jens A. Koch', 'author_id': 1163786, 'author_profile': 'https://Stackoverflow.com/users/1163786', 'pm_score': 6, 'selected': False, 'text': '<pre><code>// remove question mark from the title bar\nsetWindowFlags(windowFlags() &amp; ~Qt::WindowContextHelpButtonHint);\n</code></pre>\n'}, {'answer_id': 45939311, 'author': 'Predelnik', 'author_id': 1269661, 'author_profile': 'https://Stackoverflow.com/users/1269661', 'pm_score': 2, 'selected': False, 'text': '<p>The following way to remove question marks by default for all the dialogs in application could be used:</p>\n\n<p>Attach the following event filter to <code>QApplication</code> somewhere at the start of your program:</p>\n\n<pre><code>  bool eventFilter (QObject *watched, QEvent *event) override\n  {\n    if (event-&gt;type () == QEvent::Create)\n      {\n        if (watched-&gt;isWidgetType ())\n          {\n            auto w = static_cast&lt;QWidget *&gt; (watched);\n            w-&gt;setWindowFlags (w-&gt;windowFlags () &amp; (~Qt::WindowContextHelpButtonHint));\n          }\n      }\n    return QObject::eventFilter (watched, event);\n  }\n</code></pre>\n'}, {'answer_id': 49905954, 'author': 'Parker Coates', 'author_id': 4757, 'author_profile': 'https://Stackoverflow.com/users/4757', 'pm_score': 5, 'selected': False, 'text': '<p>As of Qt 5.10, you can disable these buttons globally with a single <code>QApplication</code> attribute!</p>\n\n<pre><code>QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);\n</code></pre>\n'}, {'answer_id': 70467468, 'author': 'Pascal Vallaster', 'author_id': 15889585, 'author_profile': 'https://Stackoverflow.com/users/15889585', 'pm_score': 2, 'selected': False, 'text': "<p>As the solution for PyQt4 from @amos didn't work for me and the version of PyQt4 is deprecated, here is my solution on how to remove the &quot;?&quot; in the dialog-box in PyQt5:</p>\n<pre><code>class window(QDialog):\n    def __init__(self):\n        super(window, self).__init__()\n        loadUi(&quot;window.ui&quot;, self)\n        self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint,False)  # This removes it\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/81627', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11212/']