Hi all, I'm having some trouble implementing drag & drop in a MDI app. My app is a QMainWindow widget which has a QMdiArea as the central widget.
In this QMdiArea I create one QMdiSubWindow and assign a custom QWidget to it using QMdiSubWindow->setWidget().
The problem is that I don't receive any dragEnter or drop events in any of all these widgets. Here's what I've done in the code for the QMainWindow, QMdiArea, QMdiSubWindow and the custom QWidget:
1.- Set the acceptDrops flag using setAcceptDrops(true);
2.- Implemented the dragEnterEvent, dropEvent and dragMoveEvent:
{
qDebug()<<"mainWND::dragEnterEvent";
//if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
{
qDebug()<<"mainWND::dropEvent";
//this->slProcessFileDrop(event->mimeData()->data("text/uri-list"));
event->acceptProposedAction();
}
{
qDebug()<<"mainWND::dragMoveEvent";
event->accept();
}
void mainWND::dragEnterEvent(QDragEnterEvent* event)
{
qDebug()<<"mainWND::dragEnterEvent";
//if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
void mainWND::dropEvent(QDropEvent* event)
{
qDebug()<<"mainWND::dropEvent";
//this->slProcessFileDrop(event->mimeData()->data("text/uri-list"));
event->acceptProposedAction();
}
void mainWND::dragMoveEvent(QDragMoveEvent* event)
{
qDebug()<<"mainWND::dragMoveEvent";
event->accept();
}
To copy to clipboard, switch view to plain text mode
(code shown here is from the QMainWindow widget, but I have the same code in all the other widgets).
As I said, I don't receive any events, not a single qDebug() statement is executed.
Could anyone throw some light in here? Am I missing anything? I've read all the documentation about QMdiArea and QMdiSubWindow but it says nothing about the drag & drop.
Thanks a lot!
Bookmarks