A
A
Armen2017-06-19 08:02:35
Qt
Armen, 2017-06-19 08:02:35

Why doesn't file drag-drop work in Linux when using Qt?

Good afternoon! Given: a list of files, you need to drag and drop to save it to a directory.
Made this work. It works great in Windows, but in Linux, when dragging outside the program window (into the file manager), the cursor becomes prohibitive. At the same time, in Linux, all other programs react to the file - i.e. the browser offers to save it, notepad shows the path, etc.
Dragdrop implementation (the file exists at the moment of dragging):

QUrl url = QUrl::fromLocalFile(fname);
QDrag* drag = new QDrag(this);
QMimeData* mimeData = new QMimeData;
mimeData->setUrls(QList<QUrl>() << url);
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);

Qt 5.8, Lubuntu 16 LTS x64 test, the same picture on regular ubuntu.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devalone, 2017-06-19
@devalone

Your code works for me, dolphin file manager. What program are you trying to drag the file into?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question