返回介绍

QWindowsMime Class

发布于 2019-10-04 15:04:06 字数 6220 浏览 1231 评论 0 收藏 0

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

#include <qmime.h>

List of all member functions.

Public Members

  • QWindowsMime ()
  • virtual ~QWindowsMime ()
  • virtual const char * convertorName () = 0
  • virtual int countCf () = 0
  • virtual int cf ( intindex ) = 0
  • virtual bool canConvert ( constchar*mime, intcf ) = 0
  • virtual const char * mimeFor ( intcf ) = 0
  • virtual int cfFor ( constchar*mime ) = 0
  • virtual QByteArray convertToMime ( QByteArraydata, constchar*mime, intcf ) = 0
  • virtual QByteArray convertFromMime ( QByteArraydata, constchar*mime, intcf ) = 0

Static Public Members

  • void initialize ()
  • QPtrList<QWindowsMime> all ()
  • QWindowsMime * convertor ( constchar*mime, intcf )
  • const char * cfToMime ( intcf )

Detailed Description

The QWindowsMime 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 QWindowsMime 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:

  • CF_UNICODETEXT - converted to "text/plain;charset=ISO-10646-UCS-2" and supported by QTextDrag.
  • CF_TEXT - converted to "text/plain;charset=system" or "text/plain" and supported by QTextDrag.
  • CF_DIB - converted to "image/*", where * is a Qt image format, and supported by QImageDrag.
  • CF_HDROP - converted to "text/uri-list", and supported by QUriDrag.

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 the Drag-and-Drop documentation for more information on choosing and definition MIME types.

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

See also Drag And Drop Classes, Input/Output and Networking and Miscellaneous Classes.


Member Function Documentation

QWindowsMime::QWindowsMime ()

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

QWindowsMime::~QWindowsMime () [virtual]

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

QPtrList<QWindowsMime> QWindowsMime::all () [static]

Returns a list of all currently defined QWindowsMime objects.

bool QWindowsMime::canConvert ( constchar*mime, intcf ) [pure virtual]

Returns TRUE if the convertor can convert (both ways) between mime and cf; otherwise returns FALSE.

All subclasses must reimplement this pure virtual function.

int QWindowsMime::cf ( intindex ) [pure virtual]

Returns the Windows Clipboard format supported by this convertor that is ordinarily at position index. This means that cf(0) returns the first Windows Clipboard format supported, and cf(countCf()-1) returns the last. If index is out of range the return value is undefined.

All subclasses must reimplement this pure virtual function.

int QWindowsMime::cfFor ( constchar*mime ) [pure virtual]

Returns the Windows Clipboard type used for MIME type mime, or 0 if this convertor does not support mime.

All subclasses must reimplement this pure virtual function.

const char * QWindowsMime::cfToMime ( intcf ) [static]

Returns a MIME type for cf, or 0 if none exists.

QByteArray QWindowsMime::convertFromMime ( QByteArraydata, constchar*mime, intcf ) [pure virtual]

Returns data converted from MIME type mime to Windows Clipboard format cf.

Note that Windows Clipboard formats must all be self-terminating. The return value may contain trailing data.

All subclasses must reimplement this pure virtual function.

QByteArray QWindowsMime::convertToMime ( QByteArraydata, constchar*mime, intcf ) [pure virtual]

Returns data converted from Windows Clipboard format cf to MIME type mime.

Note that Windows Clipboard formats must all be self-terminating. The input data may contain trailing data.

All subclasses must reimplement this pure virtual function.

QWindowsMime* QWindowsMime::convertor ( constchar*mime, intcf ) [static]

Returns the most-recently created QWindowsMime that can convert between the mime and cf formats. Returns 0 if no such convertor exists.

const char * QWindowsMime::convertorName () [pure virtual]

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

int QWindowsMime::countCf () [pure virtual]

Returns the number of Windows Clipboard formats supported by this convertor.

All subclasses must reimplement this pure virtual function.

void QWindowsMime::initialize () [static]

This is an internal function.

const char * QWindowsMime::mimeFor ( intcf ) [pure virtual]

Returns the MIME type used for Windows Clipboard format cf, or 0 if this convertor does not support cf.

All subclasses must reimplement this pure virtual function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文