summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qdragobject.3qt
blob: 449f67a65a01771cc533e0958e2c30e546ab5530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
'\" t
.TH QDragObject 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QDragObject \- Encapsulates MIME-based data transfer
.SH SYNOPSIS
\fC#include <qdragobject.h>\fR
.PP
Inherits QObject and QMimeSource.
.PP
Inherited by QStoredDrag, QTextDrag, QImageDrag, and QIconDrag.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQDragObject\fR ( QWidget * dragSource = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual \fB~QDragObject\fR ()"
.br
.ti -1c
.BI "bool \fBdrag\fR ()"
.br
.ti -1c
.BI "bool \fBdragMove\fR ()"
.br
.ti -1c
.BI "void \fBdragCopy\fR ()"
.br
.ti -1c
.BI "void \fBdragLink\fR ()"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( QPixmap pm )"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( QPixmap pm, const QPoint & hotspot )"
.br
.ti -1c
.BI "QPixmap \fBpixmap\fR () const"
.br
.ti -1c
.BI "QPoint \fBpixmapHotSpot\fR () const"
.br
.ti -1c
.BI "QWidget * \fBsource\fR ()"
.br
.ti -1c
.BI "enum \fBDragMode\fR { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "QWidget * \fBtarget\fR ()"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual bool \fBdrag\fR ( DragMode mode )"
.br
.in -1c
.SH DESCRIPTION
The QDragObject class encapsulates MIME-based data transfer.
.PP
QDragObject is the base class for all data that needs to be transferred between and within applications, both for drag and drop and for the clipboard.
.PP
See the Drag-and-drop documentation for an overview of how to provide drag and drop in your application.
.PP
See the QClipboard documentation for an overview of how to provide cut-and-paste in your application.
.PP
The drag() function is used to start a drag operation. You can specify the DragMode in the call or use one of the convenience functions dragCopy(), dragMove() or dragLink(). The drag source where the data originated is retrieved with source(). If the data was dropped on a widget within the application, target() will return a pointer to that widget. Specify the pixmap to display during the drag with setPixmap().
.PP
See also Drag And Drop Classes.
.SS "Member Type Documentation"
.SH "QDragObject::DragMode"
This enum describes the possible drag modes.
.TP
\fCQDragObject::DragDefault\fR - The mode is determined heuristically.
.TP
\fCQDragObject::DragCopy\fR - The data is copied, never moved.
.TP
\fCQDragObject::DragMove\fR - The data is moved, if dragged at all.
.TP
\fCQDragObject::DragLink\fR - The data is linked, if dragged at all.
.TP
\fCQDragObject::DragCopyOrMove\fR - The user chooses the mode by using a control key to switch from the default.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QDragObject::QDragObject ( QWidget * dragSource = 0, const char * name = 0 )"
Constructs a drag object called \fIname\fR, which is a child of \fIdragSource\fR.
.PP
Note that the drag object will be deleted when \fIdragSource\fR is deleted.
.SH "QDragObject::~QDragObject ()\fC [virtual]\fR"
Destroys the drag object, canceling any drag and drop operation in which it is involved, and frees up the storage used.
.SH "bool QDragObject::drag ()"
Starts a drag operation using the contents of this object, using DragDefault mode.
.PP
The function returns TRUE if the caller should delete the original copy of the dragged data (but see target()); otherwise returns FALSE.
.PP
If the drag contains \fIreferences\fR to information (e.g. file names in a QUriDrag are references) then the return value should always be ignored, as the target is expected to manipulate the referred-to content directly. On X11 the return value should always be correct anyway, but on Windows this is not necessarily the case (e.g. the file manager starts a background process to move files, so the source \fImust not\fR delete the files!)
.PP
Note that on Windows the drag operation will spin a blocking modal event loop that will not dispatch any QTimers.
.PP
Example: dirview/dirview.cpp.
.SH "bool QDragObject::drag ( DragMode mode )\fC [virtual protected]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Starts a drag operation using the contents of this object.
.PP
At this point, the object becomes owned by Qt, not the application. You should not delete the drag object or anything it references. The actual transfer of data to the target application will be done during future event processing - after that time the drag object will be deleted.
.PP
Returns TRUE if the dragged data was dragged as a \fImove\fR, indicating that the caller should remove the original source of the data (the drag object must continue to have a copy); otherwise returns FALSE.
.PP
The \fImode\fR specifies the drag mode (see QDragObject::DragMode.) Normally one of the simpler drag(), dragMove(), or dragCopy() functions would be used instead.
.SH "void QDragObject::dragCopy ()"
Starts a drag operation using the contents of this object, using DragCopy mode. Be sure to read the constraints described in drag().
.PP
See also drag(), dragMove(), and dragLink().
.PP
Example: iconview/simple_dd/main.cpp.
.SH "void QDragObject::dragLink ()"
Starts a drag operation using the contents of this object, using DragLink mode. Be sure to read the constraints described in drag().
.PP
See also drag(), dragCopy(), and dragMove().
.SH "bool QDragObject::dragMove ()"
Starts a drag operation using the contents of this object, using DragMove mode. Be sure to read the constraints described in drag().
.PP
See also drag(), dragCopy(), and dragLink().
.SH "QPixmap QDragObject::pixmap () const"
Returns the currently set pixmap (which isNull() if none is set).
.SH "QPoint QDragObject::pixmapHotSpot () const"
Returns the currently set pixmap hotspot.
.SH "void QDragObject::setPixmap ( QPixmap pm, const QPoint & hotspot )\fC [virtual]\fR"
Set the pixmap \fIpm\fR to display while dragging the object. The platform-specific implementation will use this where it can - so provide a small masked pixmap, and do not assume that the user will actually see it. For example, cursors on Windows 95 are of limited size.
.PP
The \fIhotspot\fR is the point on (or off) the pixmap that should be under the cursor as it is dragged. It is relative to the top-left pixel of the pixmap.
.PP
\fBWarning:\fR We have seen problems with drag cursors on different graphics hardware and driver software on Windows. Setting the graphics acceleration in the display settings down one tick solved the problems in all cases.
.PP
Example: fileiconview/qfileiconview.cpp.
.SH "void QDragObject::setPixmap ( QPixmap pm )\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Uses a hotspot that positions the pixmap below and to the right of the mouse pointer. This allows the user to clearly see the point on the window which they are dragging the data onto.
.SH "QWidget * QDragObject::source ()"
Returns a pointer to the drag source where this object originated.
.SH "QWidget * QDragObject::target ()\fC [static]\fR"
After the drag completes, this function will return the QWidget which received the drop, or 0 if the data was dropped on another application.
.PP
This can be useful for detecting the case where drag and drop is
to and from the same widget.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qdragobject.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qdragobject.3qt) and the Qt
version (3.3.8).