This is my sample program for Qlineedit Completer. After Autosuggestion i want to display the text as starting of the item in line edit for that i wrote completer.activated.connect(lambda: QTimer.singleShot(0, lambda: edit.home(False)))
. Its working fine but i dont want to show cursor at the begging and last after autosuggestion.
Given below is my code:
import sys
from PyQt4.QtCore import Qt,QTimer
from PyQt4.QtGui import QApplication, QCompleter, QLineEdit, QStringListModel
def get_data(model):
model.setStringList(["completionProgramxxxxxxxxxxxxxxx", "completionProgramyyyyyy","truthordisabled", "storecredit", "iamhere"])
if __name__ == "__main__":
app = QApplication(sys.argv)
edit = QLineEdit()
completer = QCompleter()
edit.setCompleter(completer)
completer.activated.connect(lambda: QTimer.singleShot(0, lambda: edit.home(False)))
model = QStringListModel()
completer.setModel(model)
get_data(model)
edit.show()
sys.exit(app.exec_())
i got the image like this: