PyQt5 QListWidget实现多列表之间item的插入拖拽
先上效果图

原理:
1.通过dropEvent事件来获取拖入的坐标pos
2.然后利用itemAt(pos)来通过坐标的方式来获取当前item的index
3.之后使用index.row() 或index.column()来获取整数值int
4.最后使用insertItem(int,item)来插入即可
源码
#-*-coding:utf-8-*-
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class DropInList(QListWidget):
task_data_Signal=pyqtSignal(list)
def __init__(self):
super(DropInList,self).__init__()
self.setAcceptDrops

本文介绍如何使用PyQt5的QListWidget实现多个列表间的item拖拽功能,包括通过dropEvent获取坐标,利用坐标获取item的index,再进行item的插入操作。
最低0.47元/天 解锁文章
1792

被折叠的 条评论
为什么被折叠?



