Changing mouse cursor in a QObject - QGraphicsItem inherited class

后端 未结 2 992
时光取名叫无心
时光取名叫无心 2021-01-27 03:32

I would like to change my mouse cursor when it is in a graphics item (MyCircle inherits from QObject and QGraphicsItem). Had my class inherited from <

2条回答
  •  粉色の甜心
    2021-01-27 04:13

    QGraphicsItem already has a method for changing the cursor, so you don't need to manually play around with hover events:

    QGraphicsItem::setCursor(const QCursor &cursor)
    

    http://doc.qt.io/qt-5/qgraphicsitem.html#setCursor

    PS: The dual inheritance of QWidget and QGraphicsItem you do is also a bad idea, only inherit from QGraphicsItem.

提交回复
热议问题