Hi everyone!
I have QListWidget who contains list of files path. This files i'm dropped from explorer,
but i don't know how to implement drag and drop from QListWidget to the desktop or explorer.
This is my try...
void FileListWidget::startDrag()
{
if (currentItem()) {
QFile src
(currentItem
()->text
());
data = src.readAll();
src.close();
mime->setData("text/uri-list", data);
drag->setMimeData(mime);
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
}
void FileListWidget::startDrag()
{
if (currentItem()) {
QByteArray data;
QFile src(currentItem()->text());
src.open(QIODevice::ReadOnly);
data = src.readAll();
src.close();
QMimeData *mime = new QMimeData;
mime->setData("text/uri-list", data);
QDrag *drag = new QDrag(this);
drag->setMimeData(mime);
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
}
}
To copy to clipboard, switch view to plain text mode
... but it's not working (error when copying file). Please explain me, what should I do to solve this problem?
P.S. Sorry for my bad English
Bookmarks