The QTestEventList class provides a list of GUI events. 更多...
头: | #include <QTestEventList> |
CMake: |
find_package(Qt6 COMPONENTS Test REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Test) |
qmake: | QT += testlib |
继承: | QList |
QTestEventList (const QTestEventList & other ) | |
QTestEventList () | |
~QTestEventList () | |
void | addDelay (int msecs ) |
void | addKeyClick (Qt::Key qtKey , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyClick (char ascii , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyClicks (const QString & keys , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyPress (Qt::Key qtKey , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyPress (char ascii , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyRelease (Qt::Key qtKey , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addKeyRelease (char ascii , Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1) |
void | addMouseClick (Qt::MouseButton button , Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(), QPoint pos = QPoint(), int delay = -1) |
void | addMouseDClick (Qt::MouseButton button , Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(), QPoint pos = QPoint(), int delay = -1) |
void | addMouseMove (QPoint pos = QPoint(), int delay = -1) |
void | addMousePress (Qt::MouseButton button , Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(), QPoint pos = QPoint(), int delay = -1) |
void | addMouseRelease (Qt::MouseButton button , Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(), QPoint pos = QPoint(), int delay = -1) |
void | clear () |
void | simulate (QWidget * w ) |
A QTestEventList can be populated with GUI events that can be stored as test data for later usage, or be replayed on any QWidget . QTestEventList provides convenience functions for populating the list.
范例:
QTestEventList events; events.addKeyClick('a'); events.addKeyClick(Qt::Key_Backspace); events.addDelay(200); QLineEdit *lineEdit = new QLineEdit(myParent); // ... events.simulate(lineEdit); events.simulate(lineEdit);
The example above simulates the user entering the character
a
followed by a backspace, waiting for 200 milliseconds and repeating it.
Constructs a new QTestEventList as a copy of other .
Constructs an empty QTestEventList.
Empties the list and destroys all stored events.
Adds a msecs milliseconds delay.
另请参阅 QTest::qWait ().
Adds a new key click to the list. The event will simulate the key qtKey with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyClick ().
这是重载函数。
Adds a new key click to the list. The event will simulate the key ascii with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyClick ().
Adds new keyboard entries to the list. The event will press the keys 采用 modifiers and wait msecs milliseconds between each key.
另请参阅 QTest::keyClicks ().
Adds a new key press to the list. The event will press the key qtKey with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyPress ().
这是重载函数。
Adds a new key press to the list. The event will press the key ascii with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyPress ().
Adds a new key release to the list. The event will release the key qtKey with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyRelease ().
这是重载函数。
Adds a new key release to the list. The event will release the key ascii with the modifier modifiers and then wait for msecs 毫秒。
另请参阅 QTest::keyRelease ().
Add a mouse click to the list. The event will click the button with optional modifiers at the position pos 采用可选 delay . The default position is the center of the widget.
另请参阅 QTest::mouseClick ().
Add a double mouse click to the list. The event will double click the button with optional modifiers at the position pos 采用可选 delay . The default position is the center of the widget.
另请参阅 QTest::mousePress ().
Adds a mouse move to the list. The event will move the mouse to the position pos . If a delay (in milliseconds) is set, the test will wait after moving the mouse. The default position is the center of the widget.
另请参阅 QTest::mousePress ().
Add a mouse press to the list. The event will press the button with optional modifiers at the position pos 采用可选 delay . The default position is the center of the widget.
另请参阅 QTest::mousePress ().
Add a mouse release to the list. The event will release the button with optional modifiers at the position pos 采用可选 delay . The default position is the center of the widget.
另请参阅 QTest::mouseRelease ().
Removes all events from the list.
Simulates the events from the list one by one on the widget w . For an example, please read the QTestEventList 类文档编制。