本页内容

TouchEventSequence QML Type

TouchEventSequence 用于构建和分发触摸事件以供测试。更多内容...

Import Statement: import QtTest

方法

  • TouchEventSequence commit()
  • TouchEventSequence move(int touchId, object item, real x, real y)
  • TouchEventSequence press(int touchId, object item, real x, real y)
  • TouchEventSequence release(int touchId, object item, real x, real y)
  • TouchEventSequence stationary(int touchId)

详细说明

通过调用TestCase.touchEvent() 可以创建一个 TouchEventSequence。该类型无法直接实例化。该类型提供的每个方法都会返回同一个对象,从而支持链式调用。

例如:

touchEvent(item).press(0).commit();

等同于:

var sequence = touchEvent(item);
sequence.press(0);
sequence.commit();

事件将传递给包含 touchEvent 中指定项的窗口。

另请参阅 TestCase::touchEvent()。

方法文档

TouchEventSequence commit()

发送由先前调用的press()、move()、release()和stationary()组合而成的触摸事件。在commit返回后,可以使用TouchEventSequence 来组合一个新的事件。

var sequence = touchEvent(target);
// Touch the middle of target with 1 point
sequence.press(1);
sequence.commit();

// Begin a new event
// Move the point to target's upper left corner
sequence.move(1, target, 0, 0);
sequence.commit();

当TouchEventSequence 对象被销毁时,会自动调用Commit方法。

TouchEventSequence move(int touchId, object item, real x = item.width / 2, real y = item.height / 2)

将touchId 移动到由x 和y 指定的位置,该位置相对于item 。

项的默认值为通过 touchEvent() 提供的值。X 和 y 的默认值为该项的中点。

TouchEventSequence press(int touchId, object item, real x = item.width / 2, real y = item.height / 2)

创建一个新点,其标识为touchId ,该点位于由x 和y 所指示的位置,该位置以item 为参考。后续对同一触摸点的使用应保持相同的touchId。

Item 默认采用通过 touchEvent() 提供的值。X 和 y 默认设为该项的中点。

TouchEventSequence release(int touchId, object item, real x = item.width / 2, real y = item.height / 2)

删除位于x 和y 所指位置(相对于item )处的touchId 。

项的默认值为通过 touchEvent() 提供的值。X 和 y 的默认值为该项的中点。

TouchEventSequence stationary(int touchId)

表示touchId 存在,但除此之外与先前事件相比没有变化。

© 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.