I got it working.
The solution was to use IndexAt() with the event->pos() from mousePressEvent.
Then I had to create a pointer to the attached model in order to use fileinfo on it.
I then insert the resulting filename into an Urllist and set the mimeData with it.
QFileSystemModel *tempmodel = qobject_cast<QFileSystemModel *>(model());
QList<QUrl>urllist;
QString filename
=tempmodel
->filePath
(tempindex
);
urllist.
append(QString("file:"+filename
));
mimeData->setUrls(urllist);
QFileSystemModel *tempmodel = qobject_cast<QFileSystemModel *>(model());
QModelIndex tempindex = indexAt(event->pos());
QMimeData *mimeData = new QMimeData;
QList<QUrl>urllist;
QString filename=tempmodel->filePath(tempindex);
urllist.append(QString("file:"+filename));
mimeData->setUrls(urllist);
To copy to clipboard, switch view to plain text mode
Now setPixmap is working as expected and mimeData contains allways the currently dragged Item.
Bookmarks