参考stack overflow python: how to query multiple selected items in qlistwidget in pyqt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from pyqt5.qtgui import *
from pyqt5.qtcore import *
from pyqt5.qtwidgets import *
listitem = [ 'a' , 'b' , 'c' , 'd' , 'e' ]
if listitem is not none and len (listitem) > 0 :
self .listwidget = qlistwidget( self )
for item in listitem:
self .listwidget.additem(item)
if multiselected:
self .listwidget.setselectionmode(qabstractitemview.extendedselection) #按住ctrl可多选
# self.listwidget.itemclicked.connect(self.listitemclick)
# self.listwidget.itemdoubleclicked.connect(self.listitemdoubleclick)
text_list = self .listwidget.selecteditems()
text = [i.text() for i in list (text_list)]
text = '_' ,join(text) # text即多选项并以_隔开
|
以上这篇pyqt5 qlistwidget选择多项并返回的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_28792801/article/details/80990674