1QDragObject(3qt) QDragObject(3qt)
2
3
4
6 QDragObject - Encapsulates MIME-based data transfer
7
9 #include <qdragobject.h>
10
11 Inherits QObject and QMimeSource.
12
13 Inherited by QStoredDrag, QTextDrag, QImageDrag, and QIconDrag.
14
15 Public Members
16 QDragObject ( QWidget * dragSource = 0, const char * name = 0 )
17 virtual ~QDragObject ()
18 bool drag ()
19 bool dragMove ()
20 void dragCopy ()
21 void dragLink ()
22 virtual void setPixmap ( QPixmap pm )
23 virtual void setPixmap ( QPixmap pm, const QPoint & hotspot )
24 QPixmap pixmap () const
25 QPoint pixmapHotSpot () const
26 QWidget * source ()
27 enum DragMode { DragDefault, DragCopy, DragMove, DragLink,
28 DragCopyOrMove }
29
30 Static Public Members
31 QWidget * target ()
32
33 Protected Members
34 virtual bool drag ( DragMode mode )
35
37 The QDragObject class encapsulates MIME-based data transfer.
38
39 QDragObject is the base class for all data that needs to be transferred
40 between and within applications, both for drag and drop and for the
41 clipboard.
42
43 See the Drag-and-drop documentation for an overview of how to provide
44 drag and drop in your application.
45
46 See the QClipboard documentation for an overview of how to provide cut-
47 and-paste in your application.
48
49 The drag() function is used to start a drag operation. You can specify
50 the DragMode in the call or use one of the convenience functions
51 dragCopy(), dragMove() or dragLink(). The drag source where the data
52 originated is retrieved with source(). If the data was dropped on a
53 widget within the application, target() will return a pointer to that
54 widget. Specify the pixmap to display during the drag with setPixmap().
55
56 See also Drag And Drop Classes.
57
58 Member Type Documentation
60 This enum describes the possible drag modes.
61
62 QDragObject::DragDefault - The mode is determined heuristically.
63
64 QDragObject::DragCopy - The data is copied, never moved.
65
66 QDragObject::DragMove - The data is moved, if dragged at all.
67
68 QDragObject::DragLink - The data is linked, if dragged at all.
69
70 QDragObject::DragCopyOrMove - The user chooses the mode by using a
71 control key to switch from the default.
72
75 Constructs a drag object called name, which is a child of dragSource.
76
77 Note that the drag object will be deleted when dragSource is deleted.
78
80 Destroys the drag object, canceling any drag and drop operation in
81 which it is involved, and frees up the storage used.
82
84 Starts a drag operation using the contents of this object, using
85 DragDefault mode.
86
87 The function returns TRUE if the caller should delete the original copy
88 of the dragged data (but see target()); otherwise returns FALSE.
89
90 If the drag contains references to information (e.g. file names in a
91 QUriDrag are references) then the return value should always be
92 ignored, as the target is expected to manipulate the referred-to
93 content directly. On X11 the return value should always be correct
94 anyway, but on Windows this is not necessarily the case (e.g. the file
95 manager starts a background process to move files, so the source must
96 not delete the files!)
97
98 Note that on Windows the drag operation will spin a blocking modal
99 event loop that will not dispatch any QTimers.
100
101 Example: dirview/dirview.cpp.
102
104 This is an overloaded member function, provided for convenience. It
105 behaves essentially like the above function.
106
107 Starts a drag operation using the contents of this object.
108
109 At this point, the object becomes owned by Qt, not the application. You
110 should not delete the drag object or anything it references. The actual
111 transfer of data to the target application will be done during future
112 event processing - after that time the drag object will be deleted.
113
114 Returns TRUE if the dragged data was dragged as a move, indicating that
115 the caller should remove the original source of the data (the drag
116 object must continue to have a copy); otherwise returns FALSE.
117
118 The mode specifies the drag mode (see QDragObject::DragMode.) Normally
119 one of the simpler drag(), dragMove(), or dragCopy() functions would be
120 used instead.
121
123 Starts a drag operation using the contents of this object, using
124 DragCopy mode. Be sure to read the constraints described in drag().
125
126 See also drag(), dragMove(), and dragLink().
127
128 Example: iconview/simple_dd/main.cpp.
129
131 Starts a drag operation using the contents of this object, using
132 DragLink mode. Be sure to read the constraints described in drag().
133
134 See also drag(), dragCopy(), and dragMove().
135
137 Starts a drag operation using the contents of this object, using
138 DragMove mode. Be sure to read the constraints described in drag().
139
140 See also drag(), dragCopy(), and dragLink().
141
143 Returns the currently set pixmap (which isNull() if none is set).
144
146 Returns the currently set pixmap hotspot.
147
149 Set the pixmap pm to display while dragging the object. The platform-
150 specific implementation will use this where it can - so provide a small
151 masked pixmap, and do not assume that the user will actually see it.
152 For example, cursors on Windows 95 are of limited size.
153
154 The hotspot is the point on (or off) the pixmap that should be under
155 the cursor as it is dragged. It is relative to the top-left pixel of
156 the pixmap.
157
158 Warning: We have seen problems with drag cursors on different graphics
159 hardware and driver software on Windows. Setting the graphics
160 acceleration in the display settings down one tick solved the problems
161 in all cases.
162
163 Example: fileiconview/qfileiconview.cpp.
164
166 This is an overloaded member function, provided for convenience. It
167 behaves essentially like the above function.
168
169 Uses a hotspot that positions the pixmap below and to the right of the
170 mouse pointer. This allows the user to clearly see the point on the
171 window which they are dragging the data onto.
172
174 Returns a pointer to the drag source where this object originated.
175
177 After the drag completes, this function will return the QWidget which
178 received the drop, or 0 if the data was dropped on another application.
179
180 This can be useful for detecting the case where drag and drop is to and
181 from the same widget.
182
183
185 http://doc.trolltech.com/qdragobject.html
186 http://www.trolltech.com/faq/tech.html
187
189 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
190 license file included in the distribution for a complete license
191 statement.
192
194 Generated automatically from the source code.
195
197 If you find a bug in Qt, please report it as described in
198 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
199 help you. Thank you.
200
201 The definitive Qt documentation is provided in HTML format; it is
202 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
203 web browser. This man page is provided as a convenience for those users
204 who prefer man pages, although this format is not officially supported
205 by Trolltech.
206
207 If you find errors in this manual page, please report them to qt-
208 bugs@trolltech.com. Please include the name of the manual page
209 (qdragobject.3qt) and the Qt version (3.3.8).
210
211
212
213Trolltech AS 2 February 2007 QDragObject(3qt)