PDA

View Full Version : QGraphicsItem hover events



stefan
18th August 2008, 11:27
I have problem with hover events on QGraphicsItem.


class itdItem : public QGraphicsItem
{
...
};
class itdNode : public itdItem
{
...
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
void hoverEnterEvent(QGraphicsSceneHoverEvent * hoverEvent);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * hoverEvent);
};

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

stefan
18th August 2008, 12:01
I forgot to allow hover events :rolleyes:

itdItem::itdItem(QGraphicsItem *parent, QGraphicsScene *scene)
: QGraphicsItem(parent,scene)
{
setAcceptHoverEvents(true);
}