Results 1 to 1 of 1

Thread: QGraphicsScene doesn't return items at point

  1. #1
    Join Date
    Apr 2013
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QGraphicsScene doesn't return items at point

    I am trying to subclass QGraphicsScene so I can have faster hover detection than checking whether mouse coordinates are in the shape() of the QGraphicsItem, since my QGraphicsItem subclasses are easy to compute mouse distance to.

    So far I have:
    Qt Code:
    1. void myScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. qDebug()<<"pos list";
    4. qDebug()<<items(event->pos(),Qt::IntersectsItemBoundingRect,Qt::DescendingOrder);
    5. qDebug()<<"rect list";
    6. qDebug()<<items(this->itemsBoundingRect());
    7. QGraphicsScene::mouseMoveEvent(event);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Since my QGraphicsItem subclasses have code for hover already, emitting the mouseMoveEvent triggers their hover as normal. The rect list lists all the items on the scene as expected, but the pos list is always empty. What could be causing this?

    EDIT: needed event->scenePos(), solved
    Last edited by russiankid; 7th April 2013 at 00:55.

Similar Threads

  1. Replies: 0
    Last Post: 14th January 2013, 19:19
  2. How to add items in a QGraphicsScene?
    By schmimona in forum Qt Programming
    Replies: 2
    Last Post: 3rd August 2011, 08:53
  3. Replies: 6
    Last Post: 22nd April 2010, 15:43
  4. Replies: 12
    Last Post: 30th May 2009, 14:29
  5. Replies: 2
    Last Post: 8th August 2006, 15:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.