Skip to content

Instantly share code, notes, and snippets.

@ynonp
Last active December 22, 2015 14:48
Show Gist options
  • Save ynonp/6487972 to your computer and use it in GitHub Desktop.
Save ynonp/6487972 to your computer and use it in GitHub Desktop.
void PuzzleWidget::mouseMoveEvent(QMouseEvent *event)
{
// ...
QByteArray src;
QDataStream io(&src, QIODevice::WriteOnly);
io << data;
mime->setData("myapp/data", src);
// ...
}
QDrag *drag = new QDrag(this);
QMimeData *mime = new QMimeData;
mime->setText("Hello World");
drag->setMimeData(mime);
void PuzzleWidget::dropEvent(QDropEvent *event)
{
// ...
if ( event->mimeData()->formats().contains("mygame/point"))
{
QByteArray data = event->mimeData()->data("mygame/point");
QDataStream io(data);
QPoint pc;
io >> pc;
}
}
void DndDemoWidget::dropEvent(QDropEvent *ev)
{
qDebug() << "DROP";
const QMimeData *mime = ev->mimeData();
if (mime->hasText())
{
qDebug() << "Got text: " << mime->text();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment