OK, solved. Here is the job I've done:
// Form Header (frmSetBackupDir class)
// Added
protected:
// Form Header (frmSetBackupDir class)
// Added
protected:
bool eventFilter(QObject *obj, QEvent *event);
To copy to clipboard, switch view to plain text mode
// Form Implementation
// Added in the CTOR
ui->lneDirBU->installEventFilter(this);
ui->lneDirBU->setAcceptDrops(true);
// Form Implementation
// Added in the CTOR
ui->lneDirBU->installEventFilter(this);
ui->lneDirBU->setAcceptDrops(true);
To copy to clipboard, switch view to plain text mode
{
if (event
->type
() == QEvent::DragEnter) {
tDragEnterEvent->acceptProposedAction();
return true;
}
else if (event
->type
() == QEvent::DragMove) {
QDragMoveEvent *tDragMoveEvent
= static_cast<QDragMoveEvent
*>
(event
);
tDragMoveEvent->acceptProposedAction();
return true;
}
else if (event
->type
() == QEvent::Drop) {
QDropEvent *tDropEvent
= static_cast<QDropEvent
*>
(event
);
tDropEvent->acceptProposedAction();
qDebug() << "OK, execute your task!";
return true;
}
else
{
// standard event processing
return QObject::eventFilter(obj, event
);
}
}
bool frmSetBackupDir::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::DragEnter)
{
QDragEnterEvent *tDragEnterEvent = static_cast<QDragEnterEvent *>(event);
tDragEnterEvent->acceptProposedAction();
return true;
}
else if (event->type() == QEvent::DragMove)
{
QDragMoveEvent *tDragMoveEvent = static_cast<QDragMoveEvent *>(event);
tDragMoveEvent->acceptProposedAction();
return true;
}
else if (event->type() == QEvent::Drop)
{
QDropEvent *tDropEvent = static_cast<QDropEvent *>(event);
tDropEvent->acceptProposedAction();
qDebug() << "OK, execute your task!";
return true;
}
else
{
// standard event processing
return QObject::eventFilter(obj, event);
}
}
To copy to clipboard, switch view to plain text mode
It seems to work. Better implementations are well accepted!
Bookmarks