voidDragenterevent (Qdragenterevent *Event);voidDropevent (Qdropevent *Event); UI->lineedit->setacceptdrops (false); This->setacceptdrops (true);//Drag-and- drop processing functionsvoidMainWindow::d ragenterevent (Qdragenterevent *Event){#if1 //Determine the drag file type, file name to receive the action if(Event->mimedata ()->hasformat ("text/uri-list")) { Event-acceptproposedaction (); }#endif}//drag and drop release handler functionvoidMainWindow::d ropevent (Qdropevent *Event){#if1qlist<QUrl> URLs =Event->mimedata ()URLs (); if(Urls.isempty ()) {return; } QString fileName=Urls.first (). Tolocalfile (); if(Filename.isempty ()) {return; } UI->lineedit->SetText (fileName);#endif}
http://blog.csdn.net/emdfans/article/details/45672679
QT Window Drag function simple application (handling dragenterevent and dropevent events, different events have different information, such as Mimedata)