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 event not work

Mouse event not work

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

    Hi!

    I try to interact with mouse in my custom QQuickItem
    qmlRegisterType<Book>(uri, 1, 0, "Book");

    To do this I implement
    void Book::mousePressEvent(QMouseEvent *event)

    But it never fires.

    I found maskedmousearea example. And it also not fires this events!!

    I found http://qt-project.org/forums/viewthread/24934/ and inside QQuickView I can catch this events, but when I propogate it directly to my item it never fires there:

    QPoint pos = event->pos();
    QQuickItem *child = this->rootObject()->childAt(pos.x(), pos.y());
    
    Book *item = qobject_cast<Book *>(child);
    if (item){
        QMouseEvent *itemEvent=new QMouseEvent(event->type(),item->mapFromScene(event->globalPos()),event->button(),event->buttons(),event->modifiers());
        QCoreApplication::sendEvent(item,itemEvent);
    
    }
    
    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