Qt:在QListWidget中拖放不起作用
我重新实现了一个QListWidget以接受文件删除。我只想使用拖放创建一个文件列表 以下是我的.cpp it实现:Qt:在QListWidget中拖放不起作用,qt,drag-and-drop,Qt,Drag And Drop,我重新实现了一个QListWidget以接受文件删除。我只想使用拖放创建一个文件列表 以下是我的.cpp it实现: #include "dropenabledlistwidget.h" DropEnabledListWidget::DropEnabledListWidget(QWidget *parent):QListWidget(parent) { this->setAcceptDrops(true); ///this->setDragDropMode(QAbs
#include "dropenabledlistwidget.h"
DropEnabledListWidget::DropEnabledListWidget(QWidget *parent):QListWidget(parent)
{
this->setAcceptDrops(true);
///this->setDragDropMode(QAbstractItemView::DragDrop);
qDebug() << "Aca toy";
}
void DropEnabledListWidget::dragEnterEvent(QDragEnterEvent *e)
{
if (e->mimeData()->hasUrls()) {
e->acceptProposedAction();
}
}
void DropEnabledListWidget::dropEvent(QDropEvent *event){
qDebug() << "Drop Event";
if (event->mimeData()->hasUrls()){
QList<QUrl> urls = event->mimeData()->urls();
for (qint32 i = 0; i < urls.size(); i++){
qDebug() << urls.at(i).path();
}
}
}
#包括“dropenabledlistwidget.h”
DropEnabledListWidget::DropEnabledListWidget(QWidget*parent):QListWidget(parent)
{
此->setAcceptDrops(true);
///此->设置DragDropMode(QAbstractItemView::DragDrop);
qDebug()mimeData()->hasURL()){
e->acceptProposedAction();
}
}
void DropEnabledListWidget::dropEvent(QDropEvent*事件){
qDebug()mimeData()->hasURL()){
QList url=event->mimeData()->url();
对于(qint32 i=0;i