Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QMimeData Class Reference
[QtCore module]

The QMimeData class provides a container for data that records information about its MIME type. More...

#include <QMimeData>

Inherits QObject.

Public Functions

  • 28 public functions inherited from QObject

Protected Functions

  • virtual QVariant retrieveData ( const QString & mimetype, QVariant::Type type ) const
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 4 static public members inherited from QObject

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


Member Function Documentation

QMimeData::QMimeData ()

Constructs a new MIME data object.

QMimeData::~QMimeData ()

Destroys the MIME data object.

void QMimeData::clear ()

Removes all the MIME type and data entries in the object.

QVariant QMimeData::colorData () const

Returns a color if the data stored in the object represents a color; otherwise returns an invalid variant.

See also setColorData().

QByteArray QMimeData::data ( const QString & mimetype ) const

Returns the data stored in the object in the format described by the MIME type specified by mimetype.

See also setData().

QStringList QMimeData::formats () const   [virtual]

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.

bool QMimeData::hasColor () const

Returns true if the object can return a color otherwise returns false.

bool QMimeData::hasFormat ( const QString & mimetype ) const   [virtual]

Returns true if the object can return data for the MIME type specified by mimetype; otherwise returns false.

bool QMimeData::hasHtml () const

Returns true if the object can return HTML otherwise returns false.

bool QMimeData::hasImage () const

Returns true if the object can return a image otherwise returns false.

bool QMimeData::hasText () const

Returns true if the object can return text otherwise returns false.

bool QMimeData::hasUrls () const

Returns true if the object can return a list of urls otherwise returns false.

QString QMimeData::html () const

Returns a string if the data stored in the object is HTML; otherwise returns an empty string.

See also setHtml().

QVariant QMimeData::imageData () const

Returns an image variant if the data stored in the object is in the correct form; otherwise returns an invalid variant.

See also setImageData().

QVariant QMimeData::retrieveData ( const QString & mimetype, QVariant::Type type ) const   [virtual protected]

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.

void QMimeData::setColorData ( const QVariant & color )

Sets the data in the object to the given color.

See also colorData().

void QMimeData::setData ( const QString & mimetype, const QByteArray & data )

Sets the data associated with the MIME type given by mimetype to the specified data.

See also data().

void QMimeData::setHtml ( const QString & html )

Sets the data in the object to the HTML in the html string.

See also html().

void QMimeData::setImageData ( const QVariant & image )

Sets the data in the object to the given image.

See also imageData().

void QMimeData::setText ( const QString & text )

Sets text as the plain text used to represent the data.

See also text().

void QMimeData::setUrls ( const QList<QUrl> & urls )

Sets the URLs stored in the MIME data object to those specified by urls.

See also urls().

QString QMimeData::text () const

Returns a plain text representation of the data.

See also setText().

QList<QUrl> QMimeData::urls () const

Returns a list of URLs contained within the MIME data object.

See also setUrls().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web