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. How to make a QQuickItem which will route mouse events to other QuickItem?
Forum Updated to NodeBB v4.3 + New Features

How to make a QQuickItem which will route mouse events to other QuickItem?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 224 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by Kofr
    #1

    I do not understand the right approach of QMouseEvent and QTouchEvent forwarding? Because there are PressEvent, MoveEvent and ReleaseEvent types which is not clear how to use when forwarding.
    Should I create a new QMouseEvents or ignore() existing to make them propagate? Or What is right approach?

    Uss case
    Goal is to accept mouse events in MapListEventsRouter which is inherited from QQuickItem and forward it to Map or List.
    MapListEventsRouter also controls height of Map and List. Idea is that when scrolling List down, first Map height is decreasing to 0, next the events should go directly to List.
    I have reimplemented

    void mousePressEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    

    to achieve desired logic, but MouseEvents do not go to Map or List. I have tried event->ignore(), QCoreApplication::sendEvent(_list, event) but with no success. Events just do not propagate to Map or List.
    What do I do wrong?

    // simplified code
    Item {
        id: root
    
    Map {
        id: aMap
        height: mapListRouter.mapHeight
       width: parent.width
    }
    ListView {
        id: aList
        height: mapListRouter.listHeight
        width: parent.width
    }
    MapListEventsRouter {
                    id: mapListRouter
                    height: parent.height
                    width: parent.width
                    map: aMap
                    list: aList
    }
    
    }
    
    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