hi,
i've got a really annoying problem with QLineEdit AND QCompleter. i develop with pyqt4 but i think it does not make any difference in this case.
my situation:
i build a QDialog with two QLineEdit elements. both are connected to a (different) QCompleter instance. i customized the behaviour of the QComleter to enable inline completion, after a defined separator has been entered.
for this purpose i connect my handler to the "activated(QString)" signal of the completer. this is emitted, when a suggested value of the QCompleter has been selected.
when this signal is emitted - i manually write the new content to the lineEdit object.
whenever i choose a suggestion of the completer by hitting enter, the "returnPressed()" signal of the QLineEdit gets fired. just after the execution of the connected slot, the signal "activated(QString)" is emitted.
the problem is, i have a custom slot connected to the returnPressed() signal of the lineEdit instances. these should just come into action if there was an eplicit "hit enter" just in the lineedit and not in the completer.
has anybody an idea how to ignore the returnPressed() signal when just choosing a suggestion from the completer?
why is there even a returnPressed() signal? the completer uses a QListView afaik - and this does not emit a returnPressed() signal.
i would really appreciate your help!
thnx - chris
here is an example, of what i do in my code:
-> it is python code - but its easily understandable
# connect the activated signal to do custom handling
self.connect(self.__completer, QtCore.SIGNAL("activated(QString)"), self.__text_activated)
# connect returnpressed() signal of the lineedit
self.connect(self.__first_line, QtCore.SIGNAL("returnPressed()"), self.__handle_first_line_enter)
self.connect(self.__second_line, QtCore.SIGNAL("returnPressed()"), self.__handle_second_line_enter)
# connect the activated signal to do custom handling
self.connect(self.__completer, QtCore.SIGNAL("activated(QString)"), self.__text_activated)
# connect returnpressed() signal of the lineedit
self.connect(self.__first_line, QtCore.SIGNAL("returnPressed()"), self.__handle_first_line_enter)
self.connect(self.__second_line, QtCore.SIGNAL("returnPressed()"), self.__handle_second_line_enter)
To copy to clipboard, switch view to plain text mode
"__handle_first_line_enter()" or "__handle_second_line_enter()" are always called befor the "__text_activated()"
this is, what it is ment to get rid of
Bookmarks