IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QWindowsMimeConverter Class

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

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QWindowsMimeConverter Class

  • Header: QWindowsMimeConverter

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Gui)

    target_link_libraries(mytarget PRIVATE Qt6::Gui)

  • qmake: QT += gui

Detailed Description

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 QWindowsMimeConverter 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 Format

Equivalent MIME type

CF_UNICODETEXT

text/plain

CF_TEXT

text/plain

CF_DIB

image/xyz, where xyz is a 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 Drag and Drop 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() and convertFromMime().

Member Function Documentation

 

QWindowsMimeConverter::QWindowsMimeConverter()

Constructs a QWindowsMimeConverter instance.

The instance is automatically registered, and will be called to convert data during clipboard or drag'n'drop operations.

[virtual] QWindowsMimeConverter::~QWindowsMimeConverter()

Constructs a QWindowsMimeConverter instance.

The instance is automatically unregistered.

[pure virtual] bool QWindowsMimeConverter::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 QWindowsMimeConverter::canConvertToMime(const QString &mimeType, IDataObject *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 QWindowsMimeConverter::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 structure.

Return true if the conversion was successful.

All subclasses must reimplement this pure virtual function.

[pure virtual] QVariant QWindowsMimeConverter::convertToMime(const QString &mimeType, IDataObject *pDataObj, QMetaType preferredType) const

Returns a 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] QList<FORMATETC> QWindowsMimeConverter::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const

Returns a QList of FORMATETC structures representing the different windows clipboard formats that can be provided for the mimeType from the mimeData.

All subclasses must reimplement this pure virtual function.

[pure virtual] QString QWindowsMimeConverter::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 QWindowsMimeConverter::registerMimeType(const QString &mimeType)

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

A mime type application/x-qt-windows-mime;value="WindowsType" will be registered as the clipboard format for WindowsType.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+