1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QMimeData Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QMimeData Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QMimeData class provides a container for data that records information about its MIME type. <a href="#details">More...</a></p>
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmimedata.html#QMimeData">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qmimedata.html#colorData">colorData</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qmimedata.html#data">data</a></b> (<i>self</i>, QString <i>mimetype</i>)</li><li><div class="fn" />QStringList <b><a href="qmimedata.html#formats">formats</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasColor">hasColor</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasFormat">hasFormat</a></b> (<i>self</i>, QString <i>mimetype</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasHtml">hasHtml</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasImage">hasImage</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasText">hasText</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmimedata.html#hasUrls">hasUrls</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qmimedata.html#html">html</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qmimedata.html#imageData">imageData</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qmimedata.html#retrieveData">retrieveData</a></b> (<i>self</i>, QString <i>mimetype</i>, QVariant.Type <i>preferredType</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setColorData">setColorData</a></b> (<i>self</i>, QVariant <i>color</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setData">setData</a></b> (<i>self</i>, QString <i>mimetype</i>, QByteArray <i>data</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setHtml">setHtml</a></b> (<i>self</i>, QString <i>html</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setImageData">setImageData</a></b> (<i>self</i>, QVariant <i>image</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setText">setText</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qmimedata.html#setUrls">setUrls</a></b> (<i>self</i>, QUrl-list <i>urls</i>)</li><li><div class="fn" />QString <b><a href="qmimedata.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />QUrl-list <b><a href="qmimedata.html#urls">urls</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QMimeData class provides a container for data that records information about its MIME type.</p>
<p>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.</p>
<p>QMimeData objects are usually created on the heap and supplied to <a href="qdrag.html">QDrag</a> or <a href="qclipboard.html">QClipboard</a> objects. This is to enable Qt to manage the memory that they use.</p>
<p>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.</p>
<p>Textual data types are stored with <a href="qmimedata.html#setText">setText</a>() and <a href="qmimedata.html#setHtml">setHtml</a>(); they can be retrieved with <a href="qmimedata.html#text">text</a>() and <a href="qmimedata.html#html">html</a>(). Visual data types are stored with <a href="qmimedata.html#setColorData">setColorData</a>() and <a href="qmimedata.html#setImageData">setImageData</a>(); they can be retrieved with <a href="qmimedata.html#colorData">colorData</a>() and <a href="qmimedata.html#imageData">imageData</a>(). The contents of the QMimeData object can be cleared with the <a href="qmimedata.html#clear">clear</a>() function.</p>
<p>Use the <a href="qmimedata.html#hasText">hasText</a>() and <a href="qmimedata.html#hasHtml">hasHtml</a>() functions to determine whether a given QMimeData object contains textual information; use <a href="qmimedata.html#hasColor">hasColor</a>() and <a href="qmimedata.html#hasImage">hasImage</a>() to determine whether it contains standard visual types.</p>
<p>Custom data can be stored in a QMimeData object: Use the <a href="qmimedata.html#setData">setData</a>() function with a standard MIME description of the data, and a <a href="qbytearray.html">QByteArray</a> 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 <a href="qbytearray.html">QByteArray</a> and explicitly store it in a QMimeData object using the following code:</p>
<pre>
QByteArray pngImage;
QMimeData *mimeData = new QMimeData;
mimeData->setData("image/png", pngImage);
</pre>
<p>Usually, it is easier to rely on QMimeData's support for <a href="qimage.html">QImage</a> and <a href="qpixmap.html">QPixmap</a> when handling images.</p>
<p>See also <a href="qclipboard.html">QClipboard</a>, <a href="qdragenterevent.html">QDragEnterEvent</a>, <a href="qdragmoveevent.html">QDragMoveEvent</a>, <a href="qdropevent.html">QDropEvent</a>, <a href="qdrag.html">QDrag</a>, and <a href="dnd.html">Drag and Drop</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMimeData" />QMimeData.__init__ (<i>self</i>)</h3><p>Constructs a new MIME data object.</p>
<h3 class="fn"><a name="clear" />QMimeData.clear (<i>self</i>)</h3><p>Removes all the MIME type and data entries in the object.</p>
<h3 class="fn"><a name="colorData" /><a href="qvariant.html">QVariant</a> QMimeData.colorData (<i>self</i>)</h3><p>Returns a color if the data stored in the object represents a color; otherwise returns an invalid variant.</p>
<p>See also <a href="qmimedata.html#setColorData">setColorData</a>().</p>
<h3 class="fn"><a name="data" /><a href="qbytearray.html">QByteArray</a> QMimeData.data (<i>self</i>, <a href="qstring.html">QString</a> <i>mimetype</i>)</h3><p>Returns the data stored in the object in the format described by the MIME type specified by <i>mimetype</i>.</p>
<p>See also <a href="qmimedata.html#setData">setData</a>().</p>
<h3 class="fn"><a name="formats" /><a href="qstringlist.html">QStringList</a> QMimeData.formats (<i>self</i>)</h3><p>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.</p>
<h3 class="fn"><a name="hasColor" />bool QMimeData.hasColor (<i>self</i>)</h3><p>Returns true if the object can return a color otherwise returns false.</p>
<h3 class="fn"><a name="hasFormat" />bool QMimeData.hasFormat (<i>self</i>, <a href="qstring.html">QString</a> <i>mimetype</i>)</h3><p>Returns true if the object can return data for the MIME type specified by <i>mimetype</i>; otherwise returns false.</p>
<h3 class="fn"><a name="hasHtml" />bool QMimeData.hasHtml (<i>self</i>)</h3><p>Returns true if the object can return HTML otherwise returns false.</p>
<h3 class="fn"><a name="hasImage" />bool QMimeData.hasImage (<i>self</i>)</h3><p>Returns true if the object can return a image otherwise returns false.</p>
<h3 class="fn"><a name="hasText" />bool QMimeData.hasText (<i>self</i>)</h3><p>Returns true if the object can return text otherwise returns false.</p>
<h3 class="fn"><a name="hasUrls" />bool QMimeData.hasUrls (<i>self</i>)</h3><p>Returns true if the object can return a list of urls otherwise returns false.</p>
<h3 class="fn"><a name="html" /><a href="qstring.html">QString</a> QMimeData.html (<i>self</i>)</h3><p>Returns a string if the data stored in the object is HTML; otherwise returns an empty string.</p>
<p>See also <a href="qmimedata.html#setHtml">setHtml</a>().</p>
<h3 class="fn"><a name="imageData" /><a href="qvariant.html">QVariant</a> QMimeData.imageData (<i>self</i>)</h3><p>Returns an image variant if the data stored in the object is in the correct form; otherwise returns an invalid variant.</p>
<p>See also <a href="qmimedata.html#setImageData">setImageData</a>().</p>
<h3 class="fn"><a name="retrieveData" /><a href="qvariant.html">QVariant</a> QMimeData.retrieveData (<i>self</i>, <a href="qstring.html">QString</a> <i>mimetype</i>, <a href="qvariant.html#Type-enum">QVariant.Type</a> <i>preferredType</i>)</h3><p>Returns a variant with the given <i>type</i> containing data for the MIME type specified by <i>mimetype</i>. If the object does not support the MIME type or variant type given, a null variant is returned instead.</p>
<h3 class="fn"><a name="setColorData" />QMimeData.setColorData (<i>self</i>, <a href="qvariant.html">QVariant</a> <i>color</i>)</h3><p>Sets the data in the object to the given <i>color</i>.</p>
<p>See also <a href="qmimedata.html#colorData">colorData</a>().</p>
<h3 class="fn"><a name="setData" />QMimeData.setData (<i>self</i>, <a href="qstring.html">QString</a> <i>mimetype</i>, <a href="qbytearray.html">QByteArray</a> <i>data</i>)</h3><p>Sets the data associated with the MIME type given by <i>mimetype</i> to the specified <i>data</i>.</p>
<p>See also <a href="qmimedata.html#data">data</a>().</p>
<h3 class="fn"><a name="setHtml" />QMimeData.setHtml (<i>self</i>, <a href="qstring.html">QString</a> <i>html</i>)</h3><p>Sets the data in the object to the HTML in the <i>html</i> string.</p>
<p>See also <a href="qmimedata.html#html">html</a>().</p>
<h3 class="fn"><a name="setImageData" />QMimeData.setImageData (<i>self</i>, <a href="qvariant.html">QVariant</a> <i>image</i>)</h3><p>Sets the data in the object to the given <i>image</i>.</p>
<p>See also <a href="qmimedata.html#imageData">imageData</a>().</p>
<h3 class="fn"><a name="setText" />QMimeData.setText (<i>self</i>, <a href="qstring.html">QString</a> <i>text</i>)</h3><p>Sets <i>text</i> as the plain text used to represent the data.</p>
<p>See also <a href="qmimedata.html#text">text</a>().</p>
<h3 class="fn"><a name="setUrls" />QMimeData.setUrls (<i>self</i>, QUrl-list <i>urls</i>)</h3><p>Sets the URLs stored in the MIME data object to those specified by <i>urls</i>.</p>
<p>See also <a href="qmimedata.html#urls">urls</a>().</p>
<h3 class="fn"><a name="text" /><a href="qstring.html">QString</a> QMimeData.text (<i>self</i>)</h3><p>Returns a plain text representation of the data.</p>
<p>See also <a href="qmimedata.html#setText">setText</a>().</p>
<h3 class="fn"><a name="urls" />QUrl-list QMimeData.urls (<i>self</i>)</h3><p>Returns a list of URLs contained within the MIME data object.</p>
<p>See also <a href="qmimedata.html#setUrls">setUrls</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|