

The dropEvent() function is where you recover the name of all the files you drop into your application.Īnd lastly, add this line into your mainwindow constructor: setAcceptDrops(true) In the mainwindow.cpp, add these lines: void MainWindow::dropEvent(QDropEvent *ev) Void dragEnterEvent(QDragEnterEvent *ev) Protected: void dropEvent(QDropEvent *ev) Reimplement the protected functions, dropEvent() and dragEnterEvent() If this does not work for you, consider writing a very small program in Qt.Ĭreate a new "Qt Gui Application" in Qt Creator.Įdit the header file, mainwindow.h, by adding the following headers: #include

I would preferable just drag & drop a file into a text area to get its path (see Tetsujin's answer) There are custom built utilities to format shares for other operating systems and sub/afp as well: Instead of Steps 2 to 4 above, once you've selected the file you can use the option+ command+ C shortcut to copy the file path. Thanks to Mateusz Szlosek for pointing out you can also use a keyboard shortcut. This also works to get the file path of folders. Just use the same steps for any file, regardless of whether it’s stored locally, on an external drive, or on a server. This should result in your document having the /Volumes/Server1/Serial Number.jpg path pasted into it.

Now go to the procedure you’re editing and paste the pathname you just copied.Select the Copy “Serial Number.jpg” as Pathname option.

