I'm trying to allow drag-and-drop of .exe unit test files into a QMainWindow
. My dragEnterEvent
looks like this:
void MainWindow::dragEnterEvent(QDragEnterEvent *e)
{
if (e->mimeData()->hasUrls())
{
QFileInfo info(e->mimeData()->urls().first().fileName()); // this works
if (info.isExecutable()) // false for .exe??
e->acceptProposedAction();
}
}
however the isExecutable()
function returns false for .exe files.
I have permissions to the file, and I've verified that the file path from info
is correctly pointing to the executable.
The answer to this question makes it seem like any file with the .exe extensions should return true
, so why is QFileInfo::isExecutable()
returning false?
Even though QFileInfo info(e->mimeData()->urls().first().fileName()
appeared to give a valid QFileInfo
for the executable, it wasn't actually fully working.
Using toLocalFile()
instead of fileName()
solved the problem.