The QUtiMimeConverter class converts between a MIME type and a UTI (统一类型标识符) 格式。 更多...
头: | #include <QUtiMimeConverter> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
Since: | Qt 6.5 |
flags | HandlerScope |
QUtiMimeConverter () | |
virtual | ~QUtiMimeConverter () |
bool | canConvert (const QString & mime , const QString & uti ) const |
virtual QList<QByteArray> | convertFromMime (const QString & mime , const QVariant & data , const QString & uti ) const = 0 |
virtual QVariant | convertToMime (const QString & mime , const QList<QByteArray> & data , const QString & uti ) const = 0 |
virtual int | count (const QMimeData * mimeData ) const |
virtual QString | mimeForUti (const QString & uti ) const = 0 |
virtual QString | utiForMime (const QString & mime ) const = 0 |
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.
A subclass of QUtiMimeConverter will automatically be registered, and active, upon instantiation.
Qt has predefined support for the following UTIs:
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 () 或 utiForMime () on each instance, starting with (and choosing) the last created instance first. The actual conversions will be done by using convertToMime () 和 convertFromMime ().
Constructs a new conversion object and adds it to the globally accessed list of available converters.
[虚拟]
QUtiMimeConverter::
~QUtiMimeConverter
()
Destroys a conversion object, removing it from the global list of available converters.
返回
true
if the converter can convert (both ways) between
mime
and
uti
;否则返回
false
.
[pure virtual]
QList
<
QByteArray
> QUtiMimeConverter::
convertFromMime
(const
QString
&
mime
, const
QVariant
&
data
, const
QString
&
uti
) const
返回 data converted from MIME type mime to Mac UTI uti .
Note that Mac UTIs must all be self-terminating. The return value may contain trailing data.
All subclasses must reimplement this pure virtual function.
[pure virtual]
QVariant
QUtiMimeConverter::
convertToMime
(const
QString
&
mime
, const
QList
<
QByteArray
> &
data
, const
QString
&
uti
) const
返回 data converted from Mac UTI uti to MIME type mime .
Note that Mac UTIs must all be self-terminating. The input data may contain trailing data.
All subclasses must reimplement this pure virtual function.
[虚拟]
int
QUtiMimeConverter::
count
(const
QMimeData
*
mimeData
) const
Returns the item count for the given mimeData
[pure virtual]
QString
QUtiMimeConverter::
mimeForUti
(const
QString
&
uti
) const
Returns the MIME type used for Mac UTI uti , or an empty string if this converter does not support converting from uti .
All subclasses must reimplement this pure virtual function.
[pure virtual]
QString
QUtiMimeConverter::
utiForMime
(const
QString
&
mime
) const
Returns the Mac UTI used for MIME type mime , or an empty string if this converter does not support converting from mime .
All subclasses must reimplement this pure virtual function.