QDragObject Class Reference
The QDragObject class encapsulates MIME-based information transfer.
More...
#include <qdragobject.h>
Inherits QMimeSource and QObject.
Inherited by QIconDrag, QImageDrag, QStoredDrag and QTextDrag.
List of all member functions.
Public Members
QDragObject ( QWidget * dragSource = 0, const char * name = 0 )Â
-
-
-
-
-
virtual voidÂ
setPixmap ( QPixmap, QPoint hotspot )Â
-
-
-
enumÂ
DragMode { DragDefault, DragCopy, DragMove, DragCopyOrMove }
Static Public Members
Protected Members
virtual boolÂ
drag ( DragMode )Â
Detailed Description
The QDragObject class encapsulates MIME-based information transfer.
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.
See the Drag-and-drop documentation for
an overview of how to provide drag-and-drop in your application.
See the QClipboard documentation for
an overview of how to provide cut-and-paste in your application.
Member Type Documentation
This enum type decides which of several types of drag each
individual drag is. The available types are:
DragDefault
- the mode is determined heuristically.
DragCopy
- the data is copied, never moved.
DragMove
- the data is moved, if dragged at all.
DragCopyOrMove
- the user chooses the mode
by using control key to switch from the default.
Member Function Documentation
QDragObject::QDragObject ( QWidget * dragSource = 0, const char * name = 0 )
Constructs a drag object which is a child of dragSource and
named name.
Note that the drag object will be deleted when dragSource is.
QDragObject::~QDragObject () [virtual]
Destructs the drag object, canceling any drag-and-drop operation
in which it is involved, and frees up the storage used.
bool QDragObject::drag ()
Starts a drag operation using the contents of this object,
using DragDefault mode.
The function returns TRUE if the caller should delete the
original copy of the dragged data (but also note target()).
Note that if the drag contains references to information
(eg. file names is 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 (eg. the file manager
starts a background process to move files, so the source
must not delete the files!).
bool QDragObject::drag ( DragMode mode ) [virtual protected]
Starts a drag operation using the contents of this object.
At this point, the object becomes owned by Qt, not the
application. You should not delete the drag object nor
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.
Returns TRUE if the dragged data was dragged as a move,
indicating that the caller should remove the original source
of the data (the drag object must continue to have a copy).
Normally one of simpler drag(), dragMove(), or dragCopy() functions
would be used instead.
Warning: in Qt 1.x, drag operations all return FALSE. This will change
in later versions - the functions are provided in this way to
assist preemptive development - code both move and copy with
Qt 1.x to be prepared.
void QDragObject::dragCopy ()
Starts a drag operation using the contents of this object,
using DragCopy mode.
See drag(DragMove) for important further information.
bool QDragObject::dragMove ()
Starts a drag operation using the contents of this object,
using DragMove mode.
QPixmap QDragObject::pixmap () const
Returns the currently set pixmap
(which isNull() if none is set).
QPoint QDragObject::pixmapHotSpot () const
Returns the currently set pixmap hotspot.
void QDragObject::setPixmap ( QPixmap pm, QPoint hotspot ) [virtual]
Set the pixmap pm to display while dragging the object.
The platform-specific
implementation will use this in a loose fashion - so provide a small masked
pixmap, but do not require that the user ever sees it in all its splendor.
In particular, cursors on Windows 95 are of limited size.
The hotspot 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.
void QDragObject::setPixmap ( QPixmap pm ) [virtual]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
QWidget * QDragObject::source ()
Returns a pointer to the drag source where this object originated.
QWidget * QDragObject::target () [static]
After the drag completes, this function will return the QWidget
which received the drop, or 0 if the data was dropped on some other
program.
This can be useful for detecting the case where drag-and-drop is to
and from the same widget.
void QDragObject::setTarget ( QWidget * t ) [static]
For internal use only.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit,
copyright © 1995-2005
Trolltech, all rights reserved.