Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Do postEvent to QtQuick2ApplicationViewer and be received automatically by qml
QtWS25 Last Chance

Do postEvent to QtQuick2ApplicationViewer and be received automatically by qml

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    diorahman
    wrote on last edited by
    #1

    Can we do postEvent to QtQuick2ApplicationViewer and be received automatically by qml?

    @

    QGuiApplication::postEvent(qApp->allWindows().at(0), new QMouseEvent( QEvent::MouseButtonPress, QPointF(10,10), Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::KeyboardModifier::NoModifier));

    // I hope I can receive the event and being catched by qml layer (since I sent an event -- mouse click events to the window)

    import QtQuick 2.0

    Rectangle {
    width: 360
    height: 360
    Text {
    text: qsTr("Hello World")
    anchors.centerIn: parent
    }
    MouseArea {
    anchors.fill: parent
    onClicked: {
    console.log("hurrah")
    }
    }
    }

    @

    Thanks!

    @diorahman

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved