0

I am trying to get the 'WhatsThis' functionality working in a QDialog-based application, so when the user clicks the little question mark in the Title Bar, a little 'about' dialog appears.

By default, clicking that button does nothing except change my mouse cursor to the 'Forbidden' cursor:

You have entered the Forbidden Zone!

Based on a previous post, I reimplemented event as follows:

def event(self, event): 
    if event.type() == QtCore.QEvent.EnterWhatsThisMode:
        print "Here is a useful message"
        return True
    return QtGui.QDialog.event(self, event)

While this prints out the desired message, I still get the 'Forbidden' cursor, even when I add the following to the above event function:

QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))

This creates an arrow temporarily, but when I bring the cursor anywhere outside the Title Bar in the app, the cursor turns Forbidden again. It's almost as if it is acting like there is a modal dialog open somewhere that needs to be executed.

How can I stop this Forbidden behavior?

Community
  • 1
  • 1
eric
  • 7,142
  • 12
  • 72
  • 138

1 Answers1

3

Insert a call to QWhatsThis.leaveWhatsThisMode() in your event handler to exit "What's this?" mode as soon as it's entered.

def event(self, event): 
    if event.type() == QtCore.QEvent.EnterWhatsThisMode:
        QtGui.QWhatsThis.leaveWhatsThisMode()
        print "Here is a useful message"
        return True
    return QtGui.QDialog.event(self, event)
user3419537
  • 4,740
  • 2
  • 24
  • 42
  • Thanks. Very weird...thanks for the link to the docs...I have never seen that class before. Qt seems to have a fractal structure. :) – eric Nov 17 '14 at 17:24