diff options
Diffstat (limited to 'doc/src/snippets/code/doc_src_dnd.qdoc')
-rw-r--r-- | doc/src/snippets/code/doc_src_dnd.qdoc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_dnd.qdoc b/doc/src/snippets/code/doc_src_dnd.qdoc new file mode 100644 index 0000000..40df804 --- /dev/null +++ b/doc/src/snippets/code/doc_src_dnd.qdoc @@ -0,0 +1,34 @@ +//! [0] +void MyQt3Widget::customStartDragFunction() +{ + QDragObject *d = new QTextDrag( myHighlightedText(), this ); + d->dragCopy(); + // do NOT delete d. +} +//! [0] + + +//! [1] +void MyQt3Widget::dragEnterEvent(QDragEnterEvent* event) +{ + event->accept( + QTextDrag::canDecode(event) || + QImageDrag::canDecode(event) + ); +} +//! [1] + + +//! [2] +void MyQt3Widget::dropEvent(QDropEvent* event) +{ + QImage image; + QString text; + + if ( QImageDrag::decode(event, image) ) { + insertImageAt(image, event->pos()); + } else if ( QTextDrag::decode(event, text) ) { + insertTextAt(text, event->pos()); + } +} +//! [2] |