Hi,

For 2 days I am stuggling with de completer in PYQT. I expect the solution to be quite simple but, can't figure it out.

I want to use the completer to show suggestions in a Popup screen under a QLineEdit. If I type in my QLineEdit everything works great, but if I fill the QLineEdit with a command (I use an on screen keyboard) the popup is not displayed.

Just to illustrate I got the problem caught in a small sample program, if I type in de QLineEdit it's OK, If I press the Button it doesn't do anything.....

Regards,
Sytse


Qt Code:
  1. import sys
  2.  
  3. def handleButton(model):
  4. edit.setText('co')
  5.  
  6. def get_data(model):
  7. model.setStringList(["completion", "data", "goes", "here"])
  8.  
  9. if __name__ == "__main__":
  10.  
  11. app = QApplication(sys.argv)
  12. edit = QLineEdit()
  13. completer = QCompleter()
  14. edit.setCompleter(completer)
  15.  
  16. model = QStringListModel()
  17. completer.setModel(model)
  18. get_data(model)
  19.  
  20. edit.textChanged.connect(completer.setCompletionPrefix)
  21.  
  22. app.button = QPushButton('Test')
  23. app.button.clicked.connect(handleButton)
  24.  
  25. edit.show()
  26. app.button.show()
  27. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode