List View

This commit is contained in:
Irony 2018-12-24 00:08:46 +08:00
parent b1bac76923
commit e5db2e65a3
20 changed files with 1034 additions and 996 deletions

View file

@ -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)

View file

@ -0,0 +1,11 @@
# QListView
## 1、显示自定义Widget
[运行](CustomWidgetItem.py)
![CustomWidgetItem](ScreenShot/CustomWidgetItem.png)
## 2、显示自定义Widget并排序
[运行](CustomWidgetSortItem.py)
![CustomWidgetSortItem](ScreenShot/CustomWidgetSortItem.gif)

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 323 KiB

After

Width:  |  Height:  |  Size: 323 KiB

View file

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 4.3 MiB

View file

Before

Width:  |  Height:  |  Size: 5 MiB

After

Width:  |  Height:  |  Size: 5 MiB

View file

Before

Width:  |  Height:  |  Size: 6.6 MiB

After

Width:  |  Height:  |  Size: 6.6 MiB

View file

@ -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)

View file

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View file

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 168 KiB