Last active
December 22, 2015 14:48
-
-
Save ynonp/6487972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void PuzzleWidget::mouseMoveEvent(QMouseEvent *event) | |
| { | |
| // ... | |
| QByteArray src; | |
| QDataStream io(&src, QIODevice::WriteOnly); | |
| io << data; | |
| mime->setData("myapp/data", src); | |
| // ... | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QDrag *drag = new QDrag(this); | |
| QMimeData *mime = new QMimeData; | |
| mime->setText("Hello World"); | |
| drag->setMimeData(mime); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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