Answers for "QDrag and Drop"

C
0

QDrag and Drop

void TestWidget::dragMoveEvent(QDragMoveEvent *event)
{
    if(event->mimeData()->hasUrls() || event->mimeData()->hasText())
        event->acceptProposedAction();
}

void TestWidget::dragEnterEvent(QDragEnterEvent *event)
{
    if(event->mimeData()->hasUrls() || event->mimeData()->hasText())
        event->acceptProposedAction();
}

void TestWidget::dropEvent(QDropEvent *event)
{
    qDebug()<<event->mimeData()->text();
}
Posted by: Guest on October-14-2021
0

QDrag and Drop

QDrag *drag = new QDrag(this);

QString text = QString("TEXT");

QMimeData *mimeData = new QMimeData();
mimeData->setText(text);

drag->setMimeData(mimeData);

Qt::DropAction dropAction = drag->exec(Qt::CopyAction|Qt::MoveAction);
Posted by: Guest on October-14-2021

Code answers related to "C"

Browse Popular Code Answers by Language