In my project, I want the user to be able to drag and drop a file onto my program and have it open as if they "browsed" for the file.
Here's my code:
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
{
if(event->mimeData()->urls().size() == 1)
{
QFileInfo inputFile = event->mimeData()->urls().at(0).toLocalFile();
if(inputFile.suffix() == "dat")
{
event->acceptProposedAction();
}
}
}
}
void MainWindow::dropEvent(QDropEvent* event)
{
inputPath = event->mimeData()->urls().at(0).toLocalFile();
on_actionOpen_Savegame_triggered();
}
Everything works as I need it to, except the drop action says "Copy" when the user is about to drop the file.
I can change the QDropAction to either Copy, Move, Link, or Ignore, but not Open... Is there anyway I can either remove the text saying "Copy" or just change it to say "Open"
Aucun commentaire:
Enregistrer un commentaire