42 #if !defined(QTESTKEYBOARD_H) 43 #define QTESTKEYBOARD_H 47 #pragma qt_no_master_include 50 #include <QtTest/qtestassert.h> 51 #include <QtTest/qtest_global.h> 52 #include <QtTest/qtestsystem.h> 53 #include <QtTest/qtestspontaneevent.h> 55 #include <QtCore/qpointer.h> 56 #include <QtGui/qapplication.h> 57 #include <QtGui/qevent.h> 58 #include <QtGui/qwidget.h> 71 Qt::KeyboardModifiers modifier,
QString text,
bool repeat,
int delay=-1)
83 if (!
qApp->notify(widget, &a))
84 QTest::qWarn(
"Keyboard event not accepted by receiving widget");
88 QString text, Qt::KeyboardModifiers modifier,
int delay=-1)
105 if (action == Click) {
119 if (action ==
Press) {
128 modifier & (Qt::ShiftModifier | Qt::ControlModifier),
QString(),
false, delay);
131 | Qt::ControlModifier | Qt::AltModifier),
QString(),
false, delay);
132 simulateEvent(widget,
true, code, modifier, text, repeat, delay);
133 }
else if (action ==
Release) {
134 simulateEvent(widget,
false, code, modifier, text, repeat, delay);
153 char ascii, Qt::KeyboardModifiers modifier,
int delay=-1)
158 sendKeyEvent(action, widget, code, text, modifier, delay);
171 for (
int i=0; i < sequence.
length(); i++)
180 {
keyEvent(Click, widget, key, modifier, delay); }
186 {
keyEvent(Click, widget, key, modifier, delay); }
194 #endif // QTESTKEYBOARD_H
The QKeyEvent class describes a key event.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
const QChar at(int i) const
Returns the character at the given index position in the string.
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
Simulates clicking a sequence of keys on a widget.
int length() const
Returns the number of characters in this string.
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static void keyClick(QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1)
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
const T * ptr(const T &t)
static void keyPress(QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static QWidget * activePopupWidget()
Returns the active popup widget.
static void qWait(int ms)
Waits for ms milliseconds.
Q_TESTLIB_EXPORT void qWarn(const char *message)
static void keyRelease(QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
#define QTEST_ASSERT(cond)
Q_TESTLIB_EXPORT char keyToAscii(Qt::Key key)
Convert a Qt Key to an ascii char value.
char toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0.
int Q_TESTLIB_EXPORT defaultKeyDelay()
KeyAction
This enum describes possible actions for key handling.
Q_TESTLIB_EXPORT Qt::Key asciiToKey(char ascii)
Convert an ascii char key value to a Qt Key value.
static void simulateEvent(QWidget *widget, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool...