.h
#ifndef FILELIST_H
#define FILELIST_H
#include <QtGui>
#include <QtCore>
{
Q_OBJECT
public:
FileList();
protected:
};
#endif
#ifndef FILELIST_H
#define FILELIST_H
#include <QtGui>
#include <QtCore>
class FileList : public QListWidget
{
Q_OBJECT
public:
FileList();
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dropEvent(QDropEvent *event);
};
#endif
To copy to clipboard, switch view to plain text mode
.cpp
#include <QtGui>
#include "fileList.h"
FileList::FileList()
{
setAlternatingRowColors(true);
dropHintItem->setText("Drop Files here...");
dropHintItem->setFlags(dropHintItem->flags() & ~(Qt::ItemIsDropEnabled));
insertItem(0, dropHintItem);
setAcceptDrops(true);
}
{
event->acceptProposedAction();
}
{
event->acceptProposedAction();
}
const QMimeData *mimeData
= event
->mimeData
();
if (mimeData->hasUrls()) {
//Insert the URLs and set flags to Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
}
event->acceptProposedAction();
}
{
event->accept();
}
#include <QtGui>
#include "fileList.h"
FileList::FileList()
{
setAlternatingRowColors(true);
dropHintItem = new QListWidgetItem;
dropHintItem->setText("Drop Files here...");
dropHintItem->setFlags(dropHintItem->flags() & ~(Qt::ItemIsDropEnabled));
insertItem(0, dropHintItem);
setAcceptDrops(true);
}
void FileList::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
void FileList::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
void FileList::dropEvent(QDropEvent *event) {
const QMimeData *mimeData = event->mimeData();
if (mimeData->hasUrls()) {
//Insert the URLs and set flags to Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
}
event->acceptProposedAction();
}
void FileList::dragLeaveEvent(QDragLeaveEvent *event)
{
event->accept();
}
To copy to clipboard, switch view to plain text mode
Bookmarks