在本页

DragEvent QML Type

提供有关拖动事件的信息。更多

Import Statement: import QtQuick

属性

方法

详细说明

拖动事件的位置可从xy 属性中获得,而keys 属性可确定事件源的拖动键。

可以使用hasColorhasHtmlhasTexthasUrls 属性确定是否存在特定拖动类型。

使用formats 属性可确定所有提供格式的列表。

可使用colorData,html,texturls 属性获取特定拖动类型。

可使用getDataAsString 获取任何可用 mimeType 的字符串版本。

属性文档

accepted : bool

此属性表示处理程序是否接受拖动事件。

默认值为 true。

action : enumeration

该属性用于保存信息源对已接受的下拉操作所要执行的操作。

下拉操作可以是

常量说明
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]

该属性包含一个网址列表(如有)。

x : real [read-only]

此属性保存拖动事件的 x 坐标。

y : real [read-only]

此属性保存拖动事件的 Y 坐标。

方法文档

void accept()

void accept(enumeration action)

接受拖动事件。

如果指定了action ,它将覆盖action 属性的值。

void acceptProposedAction()

通过proposedAction 接受拖动事件。

string getDataAsArrayBuffer(string format)

将给定format 的数据返回到 ArrayBuffer 中,ArrayBuffer 可以很容易地转换成QByteArrayformat 应该是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.