Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QTextDrag Class Reference

The QTextDrag class is a drag and drop object for transferring plain and Unicode text. More...

    #include <QTextDrag>

Inherits QDragObject.

- List of all members, including inherited members
- Obsolete members

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- QTextDrag ( const QString & text, QWidget * dragSource = 0 )
- QTextDrag ( QWidget * dragSource = 0 )
- ~QTextDrag ()
- virtual void setSubtype ( const QString & subtype )
- virtual void setText ( const QString & text )

- 9 public functions inherited from QDragObject
- 24 public functions inherited from QObject
- 4 public functions inherited from QMimeSource

### Public Slots

- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- bool canDecode ( const QMimeSource * source )
- bool decode ( const QMimeSource * source, QString & string )
- bool decode ( const QMimeSource * source, QString & string, QString & subtype )

- 1 static public member inherited from QDragObject
- 4 static public members inherited from QObject

### Protected Functions

- 1 protected function inherited from QDragObject
- 9 protected functions inherited from QObject

## Detailed Description

The QTextDrag class is a drag and drop object for transferring plain and Unicode text.

Plain text is passed in a QString which may contain multiple lines (i.e. may contain newline characters). The drag target will receive the newlines according to the runtime environment, e.g. LF on Unix, and CRLF on Windows.

Qt provides no built-in mechanism for delivering only a single-line.

For more information about drag and drop, see the QDragObject class and the drag and drop documentation.

## Member Function Documentation

### QTextDrag::QTextDrag ( const QString & text, QWidget * dragSource = 0 )

Constructs a text drag object for the given dragSource and sets its data to text. The dragSource is passed to the QDragObject constructor.

### QTextDrag::QTextDrag ( QWidget * dragSource = 0 )

Constructs a default text drag object for the given dragSource. The dragSource is passed to the QDragObject constructor.

### QTextDrag::~QTextDrag ()

Destroys the text drag object.

### bool QTextDrag::canDecode ( const QMimeSource * source ) `[static]`

Returns true if the information in the MIME source can be decoded into a QString; otherwise returns false.

See also decode().

### bool QTextDrag::decode ( const QMimeSource * source, QString & string ) `[static]`

Attempts to decode the dropped information in the MIME source into the string given. Returns true if successful; otherwise returns false.

See also canDecode().

### bool QTextDrag::decode ( const QMimeSource * source, QString & string, QString & subtype ) `[static]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Attempts to decode the dropped information in the MIME source into the string given. Returns true if successful; otherwise returns false. If subtype is null, any text subtype is accepted; otherwise only the specified subtype is accepted.

See also canDecode().

### void QTextDrag::setSubtype ( const QString & subtype ) `[virtual]`

Sets the MIME subtype of the text being dragged. The default subtype is "plain", so the default MIME type of the text is "text/plain". You might use this to declare that the text is "text/html" by calling setSubtype("html").

### void QTextDrag::setText ( const QString & text ) `[virtual]`

Sets the text to be dragged. You will need to call this if you did not pass the text during construction.