TQDragObject(3qt)

NAME
TQDragObject - Encapsulates MIME-based data transfer

SYNOPSIS
#include <tqdragobject.h>

Inherits TQObject and TQMimeSource.

Inherited by TQStoredDrag, TQTextDrag, TQImageDrag, and TQIconDrag.

  Public Members
TQDragObject ( TQWidget * dragSource = 0, const char * name = 0 )
virtual ~TQDragObject ()
bool drag ()
bool dragMove ()
void dragCopy ()
void dragLink ()
virtual void setPixmap ( TQPixmap pm )
virtual void setPixmap ( TQPixmap pm, const TQPoint & hotspot )
TQPixmap pixmap () const
TQPoint pixmapHotSpot () const
TQWidget * source ()
enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }

  Static Public Members
TQWidget * target ()

  Protected Members
virtual bool drag ( DragMode mode )

DESCRIPTION
The TQDragObject class encapsulates MIME-based data transfer.

TQDragObject 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 TQClipboard documentation for an overview of how to provide cut-and-paste in your application.

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().

See also Drag And Drop Classes.

  Member Type Documentation

TQDragObject::DragMode
This enum describes the possible drag modes.

TQDragObject::DragDefault - The mode is determined heuristically.

TQDragObject::DragCopy - The data is copied, never moved.

TQDragObject::DragMove - The data is moved, if dragged at all.

TQDragObject::DragLink - The data is linked, if dragged at all.

TQDragObject::DragCopyOrMove - The user chooses the mode by using a control key to switch from the default.

MEMBER FUNCTION DOCUMENTATION

TQDragObject::TQDragObject ( TQWidget * dragSource = 0, const char * name = 0 )
Constructs a drag object called name, which is a child of dragSource.

Note that the drag object will be deleted when dragSource is deleted.

TQDragObject::~TQDragObject () [virtual]
Destroys the drag object, canceling any drag and drop operation in which it is involved, and frees up the storage used.

bool TQDragObject::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 see target()); otherwise returns false.

If the drag contains references to information (e.g. file names in a TQUriDrag 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 must not delete the files!)

Note that on Windows the drag operation will spin a blocking modal event loop that will not dispatch any TQTimers.

Example: dirview/dirview.cpp.

bool TQDragObject::drag ( DragMode mode ) [virtual protected]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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 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.

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); otherwise returns false.

The mode specifies the drag mode (see TQDragObject::DragMode.) Normally one of the simpler drag(), dragMove(), or dragCopy() functions would be used instead.

void TQDragObject::dragCopy ()
Starts a drag operation using the contents of this object, using DragCopy mode. Be sure to read the constraints described in drag().

See also drag(), dragMove(), and dragLink().

Example: iconview/simple_dd/main.cpp.

void TQDragObject::dragLink ()
Starts a drag operation using the contents of this object, using DragLink mode. Be sure to read the constraints described in drag().

See also drag(), dragCopy(), and dragMove().

bool TQDragObject::dragMove ()
Starts a drag operation using the contents of this object, using DragMove mode. Be sure to read the constraints described in drag().

See also drag(), dragCopy(), and dragLink().

TQPixmap TQDragObject::pixmap () const
Returns the currently set pixmap (which isNull() if none is set).

TQPoint TQDragObject::pixmapHotSpot () const
Returns the currently set pixmap hotspot.

void TQDragObject::setPixmap ( TQPixmap pm, const TQPoint & hotspot ) [virtual]
Set the pixmap pm 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.

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.

Warning: 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.

Example: fileiconview/tqfileiconview.cpp.

void TQDragObject::setPixmap ( TQPixmap pm ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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.

TQWidget * TQDragObject::source ()
Returns a pointer to the drag source where this object originated.

TQWidget * TQDragObject::target () [static]
After the drag completes, this function will return the TQWidget which received the drop, or 0 if the data was dropped on another application.

This can be useful for detecting the case where drag and drop is to and from the same widget.

SEE ALSO
http://doc.trolltech.com/tqdragobject.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt 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.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (tqdragobject.3qt) and the Qt version (3.3.8).