deusinvictus
28th October 2013, 20:17
I'm trying to implement some Drag and Drop functionality in a program, and I only want to accept text files. Based off an example I found online I'm using the following funciton
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasText())
{
event->acceptProposedAction();
}
}
If I drag a text file onto it from Explorer (only tested under Windows 7 65 bit so far) the code functions correctly. Where I'm getting confused and am not finding much documentation, is if I drag a non-text file onto it such as a BMP, PNG, PDF (the only three binary files I've tested with so far) the hasText() functions returns true. Any one have any suggestions as to what I may be doing wrong?
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasText())
{
event->acceptProposedAction();
}
}
If I drag a text file onto it from Explorer (only tested under Windows 7 65 bit so far) the code functions correctly. Where I'm getting confused and am not finding much documentation, is if I drag a non-text file onto it such as a BMP, PNG, PDF (the only three binary files I've tested with so far) the hasText() functions returns true. Any one have any suggestions as to what I may be doing wrong?