一、在Widget中插入tableWidget
二、属性设置,添加时间过滤
ui.tableWidget->setDragDropMode(QAbstractItemView::DragDrop);
ui.tableWidget->viewport()->installEventFilter(this);
ui.tableWidget->setDragEnabled(true);
三、根据属性重写事件过滤函数
bool SoloSWGeometryForm::eventFilter(QObject *obj, QEvent *eve)
{
if (obj == ui.tableWidget->viewport())
{
if (eve->type() == QEvent::Drop)
{
const QMimeData *mime = ((QDropEvent*)eve)->mimeData();
QByteArray encodedata = mime->data("application/x-qabstractitemmodeldatalist");
if (encodedata.isEmpty())
{
return false;
}
QDataStream stream(&encodedata, QIODevice::ReadOnly);
while (!stream.atEnd())
{
int row, col;
QMap<int, QVariant>