DragEvent QML Type (Uncreatable)
提供有关拖动事件的信息。更多...
| Import Statement: | import QtQuick |
注意:这是一个不可创建的类型。无法在 QML 中对其进行实例化。
属性
- accepted : bool
- action : enumeration
- colorData : color
- formats : stringlist
- hasColor : bool
- hasHtml : bool
- hasText : bool
- hasUrls : bool
- html : string
- keys : stringlist
- proposedAction : flags
- source : QtObject
- supportedActions : flags
- text : string
- urls : urllist
- x : real
- y : real
方法
- void accept()
- void accept(enumeration action)
- void acceptProposedAction()
- string getDataAsArrayBuffer(string format)
- string getDataAsString(string format)
详细说明
拖动事件的位置可通过x 和y 属性获取,而keys 属性则用于识别事件的拖动键source 。
可以通过hasColor 、hasHtml 、hasText 和hasUrls 属性来确定特定拖拽类型是否存在。
可通过formats 属性确定所有提供的格式列表。
可通过colorData 、html 、text 和urls 属性获取具体的拖拽类型。
可通过getDataAsString 获取任何可用 mimeType 的字符串版本。
属性文档
accepted : bool
该属性表示拖动事件是否已被处理程序接受。
默认值为 true。
action : enumeration
该属性存储了source 在接收到拖放操作时应执行的操作。
该拖放操作可以是以下之一:
| 常量 | 描述 |
|---|---|
Qt.CopyAction | 将数据复制到目标。 |
Qt.MoveAction | 将数据从源移动到目标。 |
Qt.LinkAction | 从源创建到目标的链接。 |
Qt.IgnoreAction | 忽略该操作(对数据不进行任何处理)。 |
colorData : color [read-only]
该属性存储颜色数据(如有)。
formats : stringlist [read-only]
该属性包含拖拽数据中包含的 MIME 类型格式的列表。
hasColor : bool [read-only]
该属性用于指示拖动事件是否包含颜色项。
hasHtml : bool [read-only]
该属性用于确定拖动事件中是否包含 HTML 项。
hasText : bool [read-only]
该属性表示拖动事件是否包含文本项。
hasUrls : bool [read-only]
无论拖拽事件包含一个还是多个 URL 项,此属性均成立。
html : string [read-only]
该属性用于存储 HTML 数据(如有)。
keys : stringlist [read-only]
该属性包含一个键列表,这些键用于标识拖动事件的数据类型或来源。
proposedAction : flags [read-only]
该属性存储了拖拽源提出的actions 集合。
source : QtObject [read-only]
该属性保存拖动事件的源。
supportedActions : flags [read-only]
该属性包含拖动源支持的actions 集合。
text : string [read-only]
该属性存储文本数据(如有)。
urls : urllist [read-only]
该属性保存了一组 URL(如有)。
x : real [read-only]
该属性保存拖动事件的 x 坐标。
y : real [read-only]
该属性存储拖动事件的 y 坐标。
方法文档
处理拖拽事件。
如果指定了action ,它将覆盖action 属性的值。
void acceptProposedAction()
通过proposedAction 处理拖动事件。
string getDataAsArrayBuffer(string format)
将给定的format 的数据返回为一个ArrayBuffer,该ArrayBuffer可轻松转换为QByteArray 。format 应为formats 属性中所包含的那个。
string getDataAsString(string format)
返回将给定的format 转换为字符串后的数据。format 应是formats 属性中包含的一个对象。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.