Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QMimeData Class Reference

Inheritance diagram for QMimeData:


List of all members.

Detailed Description

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, {Drag and Drop}

Definition at line 35 of file qmimedata.h.

Public Slots

void deleteLater ()


void destroyed (QObject *=0)

Public Member Functions

bool blockSignals (bool b)
const QObjectListchildren () const
void clear ()
QVariant colorData () const
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
QByteArray data (const QString &mimetype) const
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void dumpObjectInfo ()
void dumpObjectTree ()
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
template<typename T>
findChild (const QString &name=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &name=QString()) const
virtual QStringList formats () const
bool hasColor () const
virtual bool hasFormat (const QString &mimetype) const
bool hasHtml () const
bool hasImage () const
bool hasText () const
bool hasUrls () const
QString html () const
QVariant imageData () const
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isWidgetType () const
void killTimer (int id)
void moveToThread (QThread *thread)
QString objectName () const
QObjectparent () const
QVariant property (const char *name) const
 QMimeData ()
void removeEventFilter (QObject *)
void setColorData (const QVariant &color)
void setData (const QString &mimetype, const QByteArray &data)
void setHtml (const QString &html)
void setImageData (const QVariant &image)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setText (const QString &text)
void setUrls (const QList< QUrl > &urls)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
int startTimer (int interval)
QString text () const
QThreadthread () const
QList< QUrlurls () const
QObjectUserData * userData (uint id) const
 ~QMimeData ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
int receivers (const char *signal) const
virtual QVariant retrieveData (const QString &mimetype, QVariant::Type preferredType) const
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject


QString objectName
 the name of this object


class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index