0

I am using python 2.7 and PyQt4 to make a gui; my experience is pretty limited. I wanted to use the QInputDialog and QMessageBox objects for some of the dialogs I need. I don't want to have the "?" in any dialogs I use. There is an answer posted on how to do this for a similar question How can I hide/delete the "?" help button on the "title bar" of a Qt Dialog?

That solution works for a standard QDialog. It amounts to:

    message = QtGui.QDialog(self, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)

This gets rid of the "?" and leaves the rest. I am not having the same results with the other classes. This is what I have tried for the QInput Dialog:

    nameDialog = QtGui.QInputDialog(self, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
    nameDialog = QtGui.QInputDialog(self, flags = QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
    nameDialog = QtGui.QInputDialog(self, flags = QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | ~QtCore.Qt.WindowContextHelpButtonHint)
    nameDialog = QtGui.QInputDialog(self, flags = QtCore.Qt.WindowTitleHint | ~QtCore.Qt.WindowContextHelpButtonHint)

or

    nameDialog = QtGui.QInputDialog(self)
    nameDialog.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
    nameDialog.setWindowFlags(QtCore.Qt.WindowContextHelpButtonHint)
    nameDialog.setWindowFlags(nameDialog.windowFlags() | ~QtCore.Qt.WindowContextHelpButtonHint)
    newUser = nameDialog.getText(self, 'User change', 'Enter name:')

None of these produced any results. The same thing happened no matter which line I used: the dialog shows up with the "?" just like it does when no second argument is included.

The QMessageBox gave me other problems when I tried to remove the "?". This is what I tried:

    mkDialog = QtGui.QMessageBox(self, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)

and

    mkDialog = QtGui.QMessageBox(self)
    mkDialog.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)

The first method gives me an error "argument 1 has unexpected type MainWin" (MainWin is the parent class). The second method displays the dialog with no title bar at all.

This question was asked before, How to remove help button on QInputDialog, but it got marked as a duplicate of the first question I posted. The same solution does not work for QInputDialog or QMessageBox as QDialog so How can I hide/delete the "?" help button on the "title bar" of a Qt Dialog? is not any help.

Any new advice would be appreciated.

Community
  • 1
  • 1
hobozero
  • 63
  • 1
  • 8
  • For `QInputDialog`, see the [comment](http://stackoverflow.com/questions/33652685/how-to-remove-help-button-on-qinputdialog#comment55086424_33652685) to the question you already linked to. – ekhumoro Jul 22 '16 at 21:10
  • Thank you. I can't believe I missed that. That takes care of the QInputDialog problem. I'm still having trouble with QMessageBox. I've tried using mkDialog.overrideWindowFlags(mkDialog.windowFlags()). That can get rid of the "?", but I get the error: "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time". The entire gui then goes behind every other window and I can't get it back on top. I've tried setting the top window flag after the override, but no luck. – hobozero Jul 24 '16 at 17:30
  • Maybe you should read through all the answers in the other question you linked to. The accepted answer isn't always the most useful one. – ekhumoro Jul 24 '16 at 23:14
  • I did read through them all. Solutions 1-3 didn't work. Solutions 4-6 I don't understand. – hobozero Jul 26 '16 at 01:01
  • By default, `QMessageBox` does not show the `What's This` question mark. Which version of PyQt4 are you using? If any of the widgets set a value using `setWhatsThis` then the question mark appears. This seems to be a bug/feature of your Window Decoration or a PyQt4 bug. – Marcus Jul 26 '16 at 17:48
  • I am using PyQt 4.11.4. It did seem odd that examples with QMessageBox didn't show the question mark, but they came up when I used it. – hobozero Jul 26 '16 at 18:00

0 Answers0