QMimeData 【Qt帮助文档】
来源:互联网 发布:多益网络原画师工资 编辑:程序博客网 时间:2024/05/19 01:10
http://doc.qt.nokia.com/latest/qmimedata.html
QMimeData Class Reference
For example, if your write a widget that accepts URL drags, you would end up writing code like this:
void MyWidget::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasUrls()) event->acceptProposedAction(); } void MyWidget::dropEvent(QDropEvent *event) { if (event->mimeData()->hasUrls()) { foreach (QUrl url, event->mimeData()->urls()) { ... } } }
There are three approaches for storing custom data in a QMimeData object:
- Custom data can be stored directly in a QMimeData object as a QByteArray using setData(). For example:
QByteArray csvData = ...; QMimeData *mimeData = new QMimeData; mimeData->setData("text/csv", csvData);
- We can subclass QMimeData and reimplement hasFormat(), formats(), and retrieveData().
- If the drag and drop operation occurs within a single application, we can subclass QMimeData and add extra data in it, and use a qobject_cast() in the receiver's drop event handler. For example:
void MyWidget::dropEvent(QDropEvent *event) { const MyMimeData *myData = qobject_cast<const MyMimeData *>(event->mimeData()); if (myData) { // access myData's data directly (not through QMimeData's API) } }
Platform-Specific MIME Types
On Windows, formats() will also return custom formats available in the MIME data, using the x-qt-windows-mime subtype to indicate that they represent data in non-standard formats. The formats will take the following form:
application/x-qt-windows-mime;value="<custom type>"
The following are examples of custom MIME types:
application/x-qt-windows-mime;value="FileGroupDescriptor" application/x-qt-windows-mime;value="FileContents"
The value declaration of each format describes the way in which the data is encoded.
On Windows, the MIME format does not always map directly to the clipboard formats. Qt provides QWindowsMime to map clipboard formats to open-standard MIME formats. Similarly, the QMacPasteboardMime maps MIME to Mac flavors.
See also QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag, QWindowsMime, QMacPasteboardMime, and Drag and Drop.
- QMimeData 【Qt帮助文档】
- QT QMimeData类
- Qt帮助文档设置
- QT帮助文档使用说明
- QMimeData
- 利用qt制作帮助文档
- Qt帮助文档使用教程
- Qt——帮助文档
- QT帮助文档风格设置
- Qt中文帮助文档,非常之方便
- 基于Qt Assistant制作软件帮助文档
- Qt 5 帮助文档的使用
- 学会使用QT的帮助文档
- 基于Qt Assistant制作软件帮助文档
- Qt下创建应用程序的帮助文档
- 利用Qt Assistant 定制帮助文档
- 利用Qt Assistant 定制帮助文档
- Qt学习笔记(2):帮助文档 (Qt助手)
- php的数据库函数中mysql_fetch_row、mysql_affected_rows、mysql_num_rows的区别
- 关于Ratio Button
- 关于用户及用户组
- Form表单中的一种输入对象Input的不同类型
- 三层结构路由协议的选择
- QMimeData 【Qt帮助文档】
- Servlet和JSP的区别
- 今天学习VI编辑器的使用方法
- 窗口拆分遇到不能运行的问题
- 翻页效果
- 正在研究一个简单的图像跟踪程序
- ADS到KEIL的转换{ 转 }
- Windows常用shell命令大全
- 周公CSDN博客文章整理