Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
QGraphicsTextItem - Accept mouse events without changing appearance
MS_GX last edited by
I am catching
QGraphicsTextItemthe following way:
class TextItem(QtWidgets.QGraphicsTextItem): def mousePressEvent(self, event): print("here")
I can see print, so this works.
However, I only get the mousePressEvent called when setting
But this way the item gets visually activated (Text is markable and box is drawn arround). I do not want that visual change. Also, I do not want the text to be selected and copy-pasted. I just want to trigger the mouse event when the text item is clicked.
How to achieve this?
JonB last edited by JonB
Purely at a guess. If that flag does selection which you do not want, and it can't be done some other way, then I would try looking at https://doc.qt.io/qt-5/qgraphicstextitem.html#sceneEvent for the mouse event, or possibly using https://doc.qt.io/qt-5/qgraphicstextitem.html#boundingRect to compare a scene mouse position against the rectangle of the text item?