【整理】Qt/PyQt QLineEdit自动补全

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【整理】Qt/PyQt QLineEdit自动补全

直接贴码:

#coding=utf-8

import sys
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QApplication, QCompleter, QLineEdit, QStringListModel

def get_data(model):
	model.setStringList(["completion", "data", "goes", "here", "cu1609", "cu1610", "cu1611"])

if __name__ == "__main__":

	app = QApplication(sys.argv)
	edit = QLineEdit()
	completer = QCompleter()
	edit.setCompleter(completer)

	model = QStringListModel()
	completer.setModel(model)
	get_data(model)

	edit.show()
	sys.exit(app.exec_())

效果图如下:

qq%e6%88%aa%e5%9b%be20160914002940

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【整理】Qt/PyQt QLineEdit自动补全

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: