PyQt/QListWidget/README.md
2018-12-24 00:08:46 +08:00

16 lines
No EOL
620 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# QListView
## 1、删除自定义Item
[运行](DeleteCustomItem.py)
1. 删除item时先要通过`QListWidget.indexFromItem(item).row()`得到它的行数
2. 通过`takeItem`函数取出该Item并删除掉,`item = self.listWidget.takeItem(row)`
3. 移除item对应的自定义控件`self.listWidget.removeItemWidget(item)`
4. 如果是清空所有Item可以通过循环删除但是删除的时候行号一直是0即可原因和删除list数组一样。
![CustomWidgetItem](ScreenShot/DeleteCustomItem.gif)
## 2、自定义可拖拽Item
[运行](DragDrop.py)
![CustomWidgetSortItem](ScreenShot/DragDrop.gif)