Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Problems suppressing keystrokes when connecting QCompleter to Q
edreamleo last edited by
I am attempting to use QCompleter connected to a (subclass of) QTextBrowser. Everything works as expected, except that I have had no joy suppressing entering of keystrokes into the QTextBrowser when the QCompleter is active. This is a show stopper.
My apps standard event filter properly catches the key events (event.type is event.ShortcutOverride). Alas, setting event.accept() does not cause they keys to be ignored later: the keys appear in the QTextBrowser. In contrast, setting event.ignore() (for the up and down arrow keys) does cause the QCompleter to recognize those keys and treat them as usual.
Similarly, having the event filter return True does not cause the QTextBrowser to ignore the keys. This looks like a bug in the interaction of QCompleter and QTextBrowser.
Can anyone suggest a way forward? Thanks.
P.S. The Python init code I use is:
cpl = self.completer = QCompleter() cpl.setWidget(self.body) # self.body is a subclass of QTextBrowser cpl.connect(cpl,QtCore.SIGNAL("activated(QString)"),completion_callback)