1、介绍
QListWidget,列表组件
2、基础使用
addItem(self, aitem: QListWidgetItem)
addItem(self, label: str)
- 添加项
addItems(self, labels: Iterable[str])
- 添加多个项
item(self, row: int) -> QListWidgetItem
- 获取指定索引的项
insertItem(self, row: int, item: QListWidgetItem)
insertItem(self, row: int, label: str)
- 指定索引处插入项
insertItems(self, row: int, labels: Iterable[str])
- 指定索引处插入多个项
3、当前项
setCurrentRow(self, row: int)
setCurrentRow(self, row: int, command: Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])
- 设置当前项
setCurrentItem(self, item: QListWidgetItem)
setCurrentItem(self, item: QListWidgetItem, command: Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])
- 设置当前项
currentRow(self) -> int
- 获取当前项的索引
currentItem(self) -> QListWidgetItem
- 获取当前项
4、事件
itemClicked(self, item: QListWidgetItem) [signal]
- 点击项时触发
itemDoubleClicked(self, item: QListWidgetItem) [signal]
- 双击某项时触发