void img_t::dragEnterEvent(QDragEnterEvent *event){ if (event->mimeData()->hasFormat("text/plain")) event->acceptProposedAction();}void img_t::dropEvent(QDropEvent *event){ QMessageBox::information(this, "",event->mimeData()->text()); event->acceptProposedAction();}
MainWindow::MainWindow(){ ... label = new QLabel( "my drop label", this ); label->setEventFilter( this ); ...}bool MainWindow::eventFilter( QObject * o, QEvent * e ){ if ( o == label ) { switch ( e->type() ) { case QEvent::DragEnter: { QDragEnterEvent * de = (QDragEnterEvent *)e; ... } break; case QEvent::Drop: { QDropEvent * de = (QDropEvent *)e; ... } break; } } return false;}
...