aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc')
-rw-r--r--doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc34
1 files changed, 34 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc b/doc/codesnippets/doc/src/snippets/code/doc_src_dnd.qdoc
new file mode 100644
index 000000000..40df804a6
--- /dev/null
+++ b/doc/codesnippets/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]