void QMimeData:: setImageData(const QVariant & image) See also html(), hasHtml(), setText(), and setData(). Sets html as the HTML (MIME type text/html) used to represent the data. void QMimeData:: setHtml(const QString & html) See also data(), hasFormat(), QMetaType, and Q_DECLARE_METATYPE(). Note that if you want to use a custom data type in an item view drag and drop operation, you must register it as a Qt meta type, using the Q_DECLARE_METATYPE() macro, and implement stream operators for it. Sets the data associated with the MIME type given by mimeType to the specified data.įor the most common types of data, you can call the higher-level functions setText(), setHtml(), setUrls(), setImageData(), and setColorData() instead. void QMimeData:: setData(const QString & mimeType, const QByteArray & data) See also colorData(), hasColor(), and setData(). Sets the color data in the object to the given color.Ĭolors correspond to the MIME type application/x-color. void QMimeData:: setColorData(const QVariant & color) You would then also need to reimplement hasFormat() and formats(). You can reimplement it if you want to store your data using a custom data structure (instead of a QByteArray, which is what setData() provides). This function is called by the general data() getter and by the convenience getters ( text(), html(), urls(), imageData(), and colorData()). If the object does not support the MIME type or variant type given, a null variant is returned instead. Returns a variant with the given type containing data for the MIME type specified by mimeType. QVariant QMimeData:: retrieveData(const QString & mimeType, QMetaType type) const Removes the data entry for mimeType in the object. void QMimeData:: removeFormat(const QString & mimeType) QImage image = qvariant_cast (event - >mimeData() - >imageData()) To convert the QVariant to a QImage, simply use qvariant_cast(). Returns a QVariant storing a QImage if the object can return an image otherwise returns a null variant.Ī QVariant is used because QMimeData belongs to the Qt Core module, whereas QImage belongs to Qt GUI. See also setHtml(), hasHtml(), and setData(). Returns a string if the data stored in the object is HTML (MIME type text/html) otherwise returns an empty string. See also setUrls(), urls(), and hasFormat(). URLs correspond to the MIME type text/uri-list. Returns true if the object can return a list of urls otherwise returns false. See also setText(), text(), hasHtml(), and hasFormat(). Returns true if the object can return plain text (MIME type text/plain) otherwise returns false. See also setImageData(), imageData(), and hasFormat(). Returns true if the object can return an image otherwise returns false. See also setHtml(), html(), and hasFormat(). Returns true if the object can return HTML (MIME type text/html) otherwise returns false. See also formats(), setData(), and data(). Returns true if the object can return data for the MIME type specified by mimeType otherwise returns false. bool QMimeData:: hasFormat(const QString & mimeType) const See also setColorData(), colorData(), and hasFormat(). Returns true if the object can return a color (MIME type application/x-color) otherwise returns false. See also hasFormat(), setData(), and data(). The formats in the list are in a priority order.įor the most common types of data, you can call the higher-level functions hasText(), hasHtml(), hasUrls(), hasImage(), and hasColor() instead. This is a list of MIME types for which the object can return suitable data. Returns a list of formats supported by the object. Returns the data stored in the object in the format described by the MIME type specified by mimeType. ![]() QByteArray QMimeData:: data(const QString & mimeType) const See also hasColor(), setColorData(), and data(). QColor color = qvariant_cast (event - >mimeData() - >colorData())
0 Comments
Leave a Reply. |