Results 1 to 2 of 2

Thread: QGraphicsItem hover events

  1. #1
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsItem hover events

    I have problem with hover events on QGraphicsItem.

    Qt Code:
    1. class itdItem : public QGraphicsItem
    2. {
    3. ...
    4. };
    5. class itdNode : public itdItem
    6. {
    7. ...
    8. QRectF boundingRect() const;
    9. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
    10. void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
    11. void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
    12. void hoverEnterEvent(QGraphicsSceneHoverEvent * hoverEvent);
    13. void hoverLeaveEvent(QGraphicsSceneHoverEvent * hoverEvent);
    14. };
    To copy to clipboard, switch view to plain text mode 

    mousePressEvent and mouseMoveEvent are working perfect, but hoverEnterEvent and hoverLeaveEvent methods are never entered. Can somebody help me on this?

  2. #2
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem hover events

    I forgot to allow hover events
    Qt Code:
    1. itdItem::itdItem(QGraphicsItem *parent, QGraphicsScene *scene)
    2. : QGraphicsItem(parent,scene)
    3. {
    4. setAcceptHoverEvents(true);
    5. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGraphicsItem hover event
    By xgoan in forum Qt Programming
    Replies: 6
    Last Post: 4th January 2016, 15:08
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  4. Replies: 9
    Last Post: 22nd June 2008, 22:26
  5. QGraphicsItem HoverEvent Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 17:40

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.