The QLineEdit is for entering post code. User may also input city name, while QCompleter will display a list of names for user to select. The problem is, on selecting the name in completer, how could the post code be put in the QLineEdit?
I tried to connect QCompleter::activated(QModelIndex) to slot that change the QLineEdit text to post code. But later the text was again set to city name by QLineEdit.
The QLineEdit is for entering post code. User may also input city name, while
Share
Sorry, my previous answer was not correct, so I’ve edited it.
As the documentation says:
I’ve got what you need by subclassing
QCompleterand reimplementingpathFromIndex:And you can use it like this: