List View
|
@ -0,0 +1,11 @@
|
||||||
|
# QListView
|
||||||
|
|
||||||
|
## 1. Custom Widget Item
|
||||||
|
[Run](CustomWidgetItem.py)
|
||||||
|
|
||||||
|
![CustomWidgetItem](ScreenShot/CustomWidgetItem.png)
|
||||||
|
|
||||||
|
## 2. Custom Widget Sort Item
|
||||||
|
[Run](CustomWidgetSortItem.py)
|
||||||
|
|
||||||
|
![CustomWidgetSortItem](ScreenShot/CustomWidgetSortItem.gif)
|
|
@ -0,0 +1,11 @@
|
||||||
|
# QListView
|
||||||
|
|
||||||
|
## 1、显示自定义Widget
|
||||||
|
[运行](CustomWidgetItem.py)
|
||||||
|
|
||||||
|
![CustomWidgetItem](ScreenShot/CustomWidgetItem.png)
|
||||||
|
|
||||||
|
## 2、显示自定义Widget并排序
|
||||||
|
[运行](CustomWidgetSortItem.py)
|
||||||
|
|
||||||
|
![CustomWidgetSortItem](ScreenShot/CustomWidgetSortItem.gif)
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 323 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 4.3 MiB After Width: | Height: | Size: 4.3 MiB |
Before Width: | Height: | Size: 5 MiB After Width: | Height: | Size: 5 MiB |
Before Width: | Height: | Size: 6.6 MiB After Width: | Height: | Size: 6.6 MiB |
|
@ -0,0 +1,16 @@
|
||||||
|
# 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)
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 168 KiB |