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. Mouse events on QQuickPaintedItem

Mouse events on QQuickPaintedItem

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

    My class is derived from QQUickPaintedItem:

    Chart::Chart(QQuickItem *parent) : QQuickPaintedItem(parent)
    {
      setAcceptedMouseButtons(Qt::AllButtons);
    }
    

    It implements mouse event functions:

    void Chart::mousePressEvent(QMouseEvent *event) {
      event->accept();
      QPointF pos = event->localPos();
      qDebug() << "mousePressEvent" << pos.x() << pos.y();
    }
    
    void Chart::mouseReleaseEvent(QMouseEvent *event) {
      event->accept();
      QPointF pos = event->localPos();
      qDebug() << "mouseReleaseEvent" << pos.x() << pos.y();
    }
    
    void Chart::mouseMoveEvent(QMouseEvent *event) {
      event->accept();
      QPointF pos = event->localPos();
      qDebug() << "mouseMoveEvent" << pos.x() << pos.y();
    }
    
    void Chart::wheelEvent(QWheelEvent *event) {
      event->accept();
      qDebug() << "wheelEvent" << event->angleDelta();
    }
    

    The QML part:

    Chart {
            width: 100; height: 100
        }
    

    I get mouser press events, mouse move events when mouse button is pressed and I get no mouse release events and no wheel events

    How to get mouse move events even when no mouse button is pressed and how to get mouse release events and wheel events?

    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