How can I simulate user interaction (key press event) in Qt ?

How can I simulate user interaction (key press event) in Qt ?

Asked on January 7, 2019 in Qt.
Add Comment


  • 3 Answer(s)

    The user interaction key press event in Qt:

    QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter);
    QCoreApplication::postEvent (receiver, event)
    
    Answered on January 7, 2019.
    Add Comment

    The given code answer is:

    QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
    QCoreApplication::postEvent (receiver, event);
    

    The no matching function for call :

    QtKeyEvent::QtKeyEvent(Type type, int key)
    

    Here is,

    QtKeyEvent::QtKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers)
    
    Answered on January 7, 2019.
    Add Comment

    QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter);
    QCoreApplication::postEvent (receiver, event)

    Answered on March 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.