Hello,

i'm having this in my code:
Qt Code:
  1. class AWBObject : public QGraphicsItem {
  2. public:
  3. // Event types.
  4. static const QEvent::Type HoverEnter = static_cast<QEvent::Type>(QEvent::User+1);
  5. static const QEvent::Type HoverLeave = static_cast<QEvent::Type>(QEvent::User+2);
  6. // Base event class.
  7. class Event : public QEvent {
  8. public:
  9. Event (QEvent::Type type) : QEvent(type) {};
  10. AWBObject *object;
  11. };
  12. // Hover enter event.
  13. class HoverEnterEvent : public AWBObject::Event {
  14. public:
  15. HoverEnterEvent () : Event(HoverEnter) {};
  16. };
  17. // Hover leave event.
  18. class HoverLeaveEvent : public AWBObject::Event {
  19. public:
  20. HoverLeaveEvent () : Event(HoverLeave) {};
  21. };
  22. [...]
  23. };
To copy to clipboard, switch view to plain text mode 

Then on a QGraphicItem "hoverEnterEvent" and "hoverLeaveEvent" i'm doing something like this:
Qt Code:
  1. if (scene()) {
  2. HoverEnterEvent *toSend = new HoverEnterEvent();
  3. toSend->object = this;
  4. QCoreApplication::sendEvent((QObject*)scene(), toSend);
  5. }
  6. QGraphicsItem::hoverEnterEvent(evt);
To copy to clipboard, switch view to plain text mode 

Then in my scene subclass:
Qt Code:
  1. void WBScene::customEvent (QEvent *evt) {
  2. switch (evt->type()) {
  3. case AWBObject::HoverEnter:
  4. _highlight = ((AWBObject::Event*)evt)->object;
  5. if (_highlight) _highlight->setHighlighted(true);
  6. return;
  7. case AWBObject::HoverLeave:
  8. _highlight = ((AWBObject::Event*)evt)->object;
  9. if (_highlight) _highlight->setHighlighted(false);
  10. return;
  11. default:
  12. return QGraphicsScene::customEvent(evt);
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 

Saddly, the event isn't received by the scene. If i post a regular event (e.g. Just propagage the QGraphicsSceneHoverEvent), it's received by the scene in the event() method. i've tried both event() and customEvent() in the scene subclass, in either case the custom event is received.

Note that i'm doing this after i instanciate my QApplication (And before execing the loop):
Qt Code:
  1. QEvent::registerEventType(AWBObject::HoverEnter);
  2. QEvent::registerEventType(AWBObject::HoverLeave);
To copy to clipboard, switch view to plain text mode