Home > Mobile >  How to drag on program files to the desktop or other position?
How to drag on program files to the desktop or other position?

Time:01-27

Want to do from the desktop and drag and drop files to the program from the program the function of the file to the desktop, from desktop drag and drop into the program has achieved
1, I don't drag the document
2, I show is not in the edit box

Drag and drop from the program to the desktop, in fact, it only need to know the news that drag and drop events to loosen and file drag and drop to the position of the path is ok, now have no clue, the great god give directions, thank!!!!!!

CodePudding user response:

Don't understand, don't know how to realize the Qt Creator is

CodePudding user response:

If you want to achieve drag from the program to the desktop, create a file on the surface of the table (don't know if this meaning), you can use the following method,
Create a temporary file, the file is you want to drag to create a file on the desktop, and then set a QMimeData QDrag, type of text/uri - list, value is the path of the temporary file, and then the operating system in the treatment of the drop automatically realize file copying,
The following code:
 
QMimeData * mimeData=https://bbs.csdn.net/topics/new QMimeData;
MimeData - & gt; SetData (" text/uri - list ", "file:///D:/abc/test");

Drag QDrag *=new QDrag;
Drag - & gt; SetMimeData (mimeData);
Drag - & gt; SetPixmap (XXX);
Drag - & gt; The exec (Qt: : CopyAction | Qt: : MoveAction, Qt: : CopyAction);
  •  Tags:  
  • Qt
  • Related