Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QMimeData class provides a container for data that records information about its MIME type. More...
#include <QMimeData>
Inherits QObject.
The QMimeData class provides a container for data that records information about its MIME type.
QMimeData is used to describe information that can be stored in the clipboard, and transferred via the drag and drop mechanism. QMimeData objects associate the data that they hold with the corresponding MIME types to ensure that information can be safely transferred between applications, and copied around within the same application.
QMimeData objects are usually created on the heap and supplied to QDrag or QClipboard objects. This is to enable Qt to manage the memory that they use.
The class provides a number of convenience functions to allow data in common formats to be stored and retrieved, and QMimeData objects can be queried to determine which kind of data they contain.
Textual data types are stored with setText() and setHtml(); they can be retrieved with text() and html(). Visual data types are stored with setColorData() and setImageData(); they can be retrieved with colorData() and imageData(). The contents of the QMimeData object can be cleared with the clear() function.
Use the hasText() and hasHtml() functions to determine whether a given QMimeData object contains textual information; use hasColor() and hasImage() to determine whether it contains standard visual types.
Custom data can be stored in a QMimeData object: Use the setData() function with a standard MIME description of the data, and a QByteArray containing the data itself. For example, although we could store an image using setImage(), we can take a Portable Network Graphics (PNG) image from a QByteArray and explicitly store it in a QMimeData object using the following code:
QByteArray pngImage; QMimeData *mimeData = new QMimeData; mimeData->setData("image/png", pngImage);
Usually, it is easier to rely on QMimeData's support for QImage and QPixmap when handling images.
See also QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag, and Drag and Drop.
Constructs a new MIME data object.
Destroys the MIME data object.
Removes all the MIME type and data entries in the object.
Returns a color if the data stored in the object represents a color; otherwise returns an invalid variant.
See also setColorData().
Returns the data stored in the object in the format described by the MIME type specified by mimetype.
See also setData().
Returns a list of formats supported by the object. This is a list of MIME types for which the object can return suitable data. The formats in the list are in a priority order.
Returns true if the object can return a color otherwise returns false.
Returns true if the object can return data for the MIME type specified by mimetype; otherwise returns false.
Returns true if the object can return HTML otherwise returns false.
Returns true if the object can return a image otherwise returns false.
Returns true if the object can return text otherwise returns false.
Returns true if the object can return a list of urls otherwise returns false.
Returns a string if the data stored in the object is HTML; otherwise returns an empty string.
See also setHtml().
Returns an image variant if the data stored in the object is in the correct form; otherwise returns an invalid variant.
See also setImageData().
Returns a variant with the given type containing data for the MIME type specified by mimetype. If the object does not support the MIME type or variant type given, a null variant is returned instead.
Sets the data in the object to the given color.
See also colorData().
Sets the data associated with the MIME type given by mimetype to the specified data.
See also data().
Sets the data in the object to the HTML in the html string.
See also html().
Sets the data in the object to the given image.
See also imageData().
Sets text as the plain text used to represent the data.
See also text().
Sets the URLs stored in the MIME data object to those specified by urls.
See also urls().
Returns a plain text representation of the data.
See also setText().
Returns a list of URLs contained within the MIME data object.
See also setUrls().
Copyright © 2006 Trolltech | Trademarks | Qt 4.1.3 |