Manipulate QGraphicsTextItems on a QGraphicsScene
Hello everyone,
I wanted to create a program for taking notes which is based on QGraphicsTextItems, I wanted to have behavior that is different from the QtTextItem which is added to a QGraphicsScene. The problem is, that for this behavior I've to change the TextItems (editable / not editable) when somewhere on the scene a click happens . The Problem is, that I can't call this functions because all the stuff which is added on the scene are just QGraphicsItems and they don't have this behavior (editable / non editable etc.).
I tried to make a list with all the QGraphicsTextItems so i could reset all of them. I couldn't find a better solution... is there another way of doing this? I thought my way isn't really object-oriented...
the program works fine but I think it's a bit inefficient ;)
Thank you for your suggestions & help
airglide
Re: Manipulate QGraphicsTextItems on a QGraphicsScene
if those items don't have that (editable) behaviour, shouldn't you be adding it to your own 'TextItems'? You can also use QGraphicsObject if you need signals/slots.
Re: Manipulate QGraphicsTextItems on a QGraphicsScene
The QGraphicsTextItem have this behavior (TextInteraction editable/non editable). If I have a QGraphicsScene there are only items and I don't know how I can get the behavior of the QGraphicsTextItem.
Re: Manipulate QGraphicsTextItems on a QGraphicsScene
you can do as you are (if I understand correctly) and keep your own list of QGraphicsTextItem*, or you can just use dynamic_cast or qobject_cast to check if QGraphicsItem is also a QGraphicsTextItem
Re: Manipulate QGraphicsTextItems on a QGraphicsScene
great I'll have a look at qobject_cast
thanks ;)