I'm trying to get my MyGraphicsRectItem (which is a subclass of QGraphicsRectItem and QObject) turn a slightly different color when I hover over it, so I've created a signal in the header file:
class MyGraphicsRectItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
...
signals:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
}
In my MyMainWindow, I'm connecting the hoverEnterEvent in this way (edit, clarification: a1 is a MyGraphicsRectItem):
connect(a1, &MyGraphicsRectItem::hoverEnterEvent, [this, i](QGraphicsSceneHoverEvent *event) {
hoverRect(event, i);
});
Unfortunately, I get a QObject::connect: signal not found in MyGraphicsRectItem
error message even though I clearly defined it in the header file. Any ideas?