QWinMime 类

The QWinMime class maps open-standard MIME to Window Clipboard formats. 更多...

头: #include <QWinMime>
qmake: QT += winextras
Since: Qt 5.4

公共函数

QWinMime ()
virtual ~QWinMime ()
virtual bool canConvertFromMime (const FORMATETC & formatetc , const QMimeData * mimeData ) const = 0
virtual bool canConvertToMime (const QString & mimeType , int * pDataObj ) const = 0
virtual bool convertFromMime (const FORMATETC & formatetc , const QMimeData * mimeData , STGMEDIUM * pmedium ) const = 0
virtual QVariant convertToMime (const QString & mimeType , int * pDataObj , QVariant::Type preferredType ) const = 0
virtual QVector<FORMATETC> formatsForMime (const QString & mimeType , const QMimeData * mimeData ) const = 0
virtual QString mimeForFormat (const FORMATETC & formatetc ) const = 0

静态公共成员

int registerMimeType (const QString & mime )

详细描述

The QWinMime class maps open-standard MIME to Window Clipboard formats.

Qt's drag-and-drop and clipboard facilities use the MIME standard. On X11, this maps trivially to the Xdnd protocol, but on Windows although some applications use MIME types to describe clipboard formats, others use arbitrary non-standardized naming conventions, or unnamed built-in formats of Windows.

By instantiating subclasses of QWinMime that provide conversions between Windows Clipboard and MIME formats, you can convert proprietary clipboard formats to MIME formats.

Qt has predefined support for the following Windows Clipboard formats:

Windows 格式 等效 MIME 类型
CF_UNICODETEXT text/plain
CF_TEXT text/plain
CF_DIB image/xyz ,其中 xyz Qt image format
CF_HDROP text/uri-list
CF_INETURL text/uri-list
CF_HTML text/html

An example use of this class would be to map the Windows Metafile clipboard format ( CF_METAFILEPICT ) to and from the MIME type image/x-wmf . This conversion might simply be adding or removing a header, or even just passing on the data. See 拖放 for more information on choosing and definition MIME types.

You can check if a MIME type is convertible using canConvertFromMime () and can perform conversions with convertToMime () 和 convertFromMime ().

成员函数文档编制

QWinMime:: QWinMime ()

Constructs a new conversion object, adding it to the globally accessed list of available converters.

[虚拟] QWinMime:: ~QWinMime ()

Destroys a conversion object, removing it from the global list of available converters.

[pure virtual] bool QWinMime:: canConvertFromMime (const FORMATETC & formatetc , const QMimeData * mimeData ) const

Returns true if the converter can convert from the mimeData to the format specified in formatetc .

All subclasses must reimplement this pure virtual function.

[pure virtual] bool QWinMime:: canConvertToMime (const QString & mimeType , int * pDataObj ) const

Returns true if the converter can convert to the mimeType from the available formats in pDataObj .

All subclasses must reimplement this pure virtual function.

[pure virtual] bool QWinMime:: convertFromMime (const FORMATETC & formatetc , const QMimeData * mimeData , STGMEDIUM * pmedium ) const

Convert the mimeData to the format specified in formatetc . The converted data should then be placed in pmedium 结构。

返回 true 若转换成功。

All subclasses must reimplement this pure virtual function.

[pure virtual] QVariant QWinMime:: convertToMime (const QString & mimeType , int * pDataObj , QVariant::Type preferredType ) const

返回 QVariant containing the converted data for mimeType from pDataObj . If possible the QVariant should be of the preferredType to avoid needless conversions.

All subclasses must reimplement this pure virtual function.

[pure virtual] QVector < FORMATETC > QWinMime:: formatsForMime (const QString & mimeType , const QMimeData * mimeData ) const

返回 QVector of FORMATETC structures representing the different windows clipboard formats that can be provided for the mimeType mimeData .

All subclasses must reimplement this pure virtual function.

[pure virtual] QString QWinMime:: mimeForFormat (const FORMATETC & formatetc ) const

Returns the mime type that will be created form the format specified in formatetc , or an empty string if this converter does not support formatetc .

All subclasses must reimplement this pure virtual function.

[static] int QWinMime:: registerMimeType (const QString & mime )

Registers the MIME type mime , and returns an ID number identifying the format on Windows.