Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide/delete the "?" help button on the "title bar" of a Qt Dialog?

Tags:

qt

qt4

qdialog

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.

like image 779
AMM Avatar asked Sep 17 '08 09:09

AMM


People also ask

What is dialog in Qt?

Dialogs can be modal, in which case the user is required to provide necessary information before work in the main window can continue, or modeless. Modeless dialogs do not prevent the user from interacting with any of the other windows in the application.


2 Answers

// remove question mark from the title bar setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); 
like image 64
Jens A. Koch Avatar answered Sep 27 '22 23:09

Jens A. Koch


By default the Qt::WindowContextHelpButtonHint flag is added to dialogs. You can control this with the WindowFlags parameter to the dialog constructor.

For instance you can specify only the TitleHint and SystemMenu flags by doing:

QDialog *d = new QDialog(0, Qt::WindowSystemMenuHint | Qt::WindowTitleHint); d->exec(); 

If you add the Qt::WindowContextHelpButtonHint flag you will get the help button back.

In PyQt you can do:

from PyQt4 import QtGui, QtCore app = QtGui.QApplication([]) d = QtGui.QDialog(None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) d.exec_() 

More details on window flags can be found on the WindowType enum in the Qt documentation.

like image 30
amos Avatar answered Sep 27 '22 22:09

amos