PDA

View Full Version : Manipulate QGraphicsTextItems on a QGraphicsScene



airglide
28th July 2012, 14:10
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

amleto
28th July 2012, 16:25
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.

airglide
28th July 2012, 16:57
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.

amleto
28th July 2012, 17:27
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

airglide
28th July 2012, 23:38
great I'll have a look at qobject_cast

thanks ;)