Loading...
Searching...
No Matches
InputEventGenerator Class Reference

This class allows injecting Key events into the scene it lives in. More...

`#include <plugins/Utils/inputeventgenerator.h>`

## Public Member Functions

| InputEventGenerator (QQuickItem *parent=0)
Q_INVOKABLE void | generateKeyEvent (Qt::Key key, bool pressed, Qt::KeyboardModifiers modifiers=Qt::NoModifier, quint64 timestamp=QDateTime::currentMSecsSinceEpoch(), quint32 nativeScanCode=0, const QString &text=QString())

## Detailed Description

This class allows injecting Key events into the scene it lives in.

Definition at line 27 of file inputeventgenerator.h.

## Constructor & Destructor Documentation

## InputEventGenerator()

InputEventGenerator::InputEventGenerator | ( | QQuickItem * | parent = 0 | ) |

Definition at line 23 of file inputeventgenerator.cpp.

: QQuickItem(parent)
{
}

## Member Function Documentation

## generateKeyEvent()

void InputEventGenerator::generateKeyEvent | ( | Qt::Key | key,
|  | bool | pressed,
|  | Qt::KeyboardModifiers | modifiers = Qt::NoModifier,
|  | quint64 | timestamp = QDateTime::currentMSecsSinceEpoch(),
|  | quint32 | nativeScanCode = 0,
|  | const QString & | text = QString() )

Generate and post and event to the scene. The key event will be sent to the scene the Generator lives in and it will be dispatched through the regular event/focus queue.

Definition at line 28 of file inputeventgenerator.cpp.

{
QEvent::Type type = pressed ? QEvent::KeyPress : QEvent::KeyRelease;
QKeyEvent ev(type, key, modifiers, nativeScanCode, 0, 0, text);
ev.setTimestamp(timestamp);
QCoreApplication::sendEvent(window(), &ev);
}

The documentation for this class was generated from the following files:

- plugins/Utils/inputeventgenerator.h
- plugins/Utils/inputeventgenerator.cpp