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

QUtiMimeConverter Class

The QUtiMimeConverter class converts between a MIME type and a Uniform Type Identifier (UTI) format.

This class was introduced in Qt 6.5.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QUtiMimeConverter Class

  • Header: QUtiMimeConverter

  • Since: Qt 6.5

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Gui)

    target_link_libraries(mytarget PRIVATE Qt6::Gui)

  • qmake: QT += gui

  • Group: QUtiMimeConverter is part of draganddrop

Detailed Description

Qt's drag and drop and clipboard facilities use the MIME standard. On X11, this maps trivially to the Xdnd protocol. On Mac, although some applications use MIME to describe clipboard contents, it is more common to use Apple's UTI format.

QUtiMimeConverter's role is to bridge the gap between MIME and UTI; By subclasses this class, one can extend Qt's drag and drop and clipboard handling to convert to and from unsupported, or proprietary, UTI formats.

Construct an instance of your converter implementation after instantiating QGuiApplication:

 
Sélectionnez
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);
    JsonMimeConverter jsonConverter;
}

Destroying the instance will unregister the converter and remove support for the conversion. It is also valid to heap-allocate the converter instance; Qt takes ownership and will delete the converter object during QGuiApplication shut-down.

Qt has predefined support for the following UTIs:

  • public.utf8-plain-text - converts to "text/plain"

  • public.utf16-plain-text - converts to "text/plain"

  • public.text - converts to "text/plain"

  • public.html - converts to "text/html"

  • public.url - converts to "text/uri-list"

  • public.file-url - converts to "text/uri-list"

  • public.tiff - converts to "application/x-qt-image"

  • public.vcard - converts to "text/plain"

  • com.apple.traditional-mac-plain-text - converts to "text/plain"

  • com.apple.pict - converts to "application/x-qt-image"

When working with MIME data, Qt will iterate through all instances of QUtiMimeConverter to find find an instance that can convert to, or from, a specific MIME type. It will do this by calling mimeForUti() or utiForMime() on each instance, starting with (and choosing) the last created instance first. The actual conversions will be done by using convertToMime() and convertFromMime().

Member Function Documentation

 

QUtiMimeConverter::QUtiMimeConverter()

Constructs a new conversion object and adds it to the globally accessed list of available converters.

Call this constructor after QGuiApplication has been created.

[virtual] QUtiMimeConverter::~QUtiMimeConverter()

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

[virtual] int QUtiMimeConverter::count(const QMimeData *mimeData) const

Returns the item count for the given mimeData

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