Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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?