我有一个小程序,我使用行编辑来自动完成。选择文本后,我的光标转到文本的末尾。那么如何将我的光标设置到起始位置呢?
我的代码:
import sys
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication, QCompleter, QLineEdit, QStringListModel
def get_data(model):
model.setStringList(["completion_xxxxxxxxxx", "data_yyyyyyyyyy", "goes_ccccccccc", "here"])
if __name__ == "__main__":
app = QApplication(sys.argv)
edit = QLineEdit()
edit.setCursorPosition(0)
completer = QCompleter()
edit.setCompleter(completer)
model = QStringListModel()
completer.setModel(model)
get_data(model)
edit.show()
sys.exit(app.exec_())
但我想这样展示它: