QEvent::Drop not called
-
Here is a sample code of what I a trying to do! When I run it QEvent::Drop is never called! I even tried using viewport() and writing a piece including dragMove but nothing works.
setAcceptDrops is true for both MainWindow and ui->EditorMdiArea
Help is much needed!
Thank You
bool MainWindow::eventFilter(QObject *pFilterObj, QEvent *event) { if((pFilterObj==ui->EditorMdiArea) && (event-type()==QEvent::Drag)) { QDragEnterEvent *devent = (QDragEnterEvent*)event; qDebug()<<"Here we are 1"; devent->acceptProposedAction(); devent->accept(); } //if((pFilterObj==ui->EditorMdiArea) && (QVariant(event->type()).toString()=="61")) { // QDragEnterEvent *devent = (QDragEnterEvent*)event; // qDebug()<<"Here we are 2"; // devent->accept(); //} qDebug()<<"pFilterObj is "<<pFilterObj; qDebug()<<"event type is "<<event->type(); //ui->EditorMdiArea->viewport()->installEventFilter(this); //ui->EditorMdiArea->viewport()->setAcceptDrops(true); if((pFilterObj==ui->EditorMdiArea) && (Qevent->type()==QEvent::Drop)) { qDebug()<<" Inside pFilterObj is "<<pFilterObj; qDebug()<<"Inside event type is "<<event->type(); QDropEvent *devent = (QDropEvent*)event; qDebug()<<"Finaly Destination Reached"; } } } } return false; }
-
Hi and welcome to devnet,
How did you setup the event filter ?
What are you trying to drop ? -
Hi and welcome to devnet,
How did you setup the event filter ?
What are you trying to drop ?@SGaist Hello! I am trying to drop a file in the ui->EditorMdiArea so as to open it o drop!
For setting up the event filter I have done the following ui->EditorMdiArea->installEventFilter(this); ui->EditorMdiArea->setAcceptDrops(true); in the constructor of the MainWindow