Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt:在QListWidget中拖放不起作用_Qt_Drag And Drop - Fatal编程技术网

Qt:在QListWidget中拖放不起作用

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

我重新实现了一个QListWidget以接受文件删除。我只想使用拖放创建一个文件列表

以下是我的.cpp it实现:

#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