PDA

View Full Version : Propery capable QGraphicsTextItem



Gopala Krishna
24th February 2007, 11:02
Hi,
I need a way to display properties of a component which are editable. For eg for resistor's property resistance -
R = 10k

What I want is the text only after '=' to be editable not before it. That is, '10k' should be alterable not 'R'. Currently I have implemented this using two QGraphicsTextItem and making one part editable but this is performance blow since it increases the number of items to be moved while many components are moved.

I feel this can be done in better faster way. I'd be glad if anyone can help me on how I can do that.

wysota
24th February 2007, 16:53
You can subclass the item and reimplement the paint method, calling the base class with a modified painter rectangle (translate the painter). As for the "static" part, draw it on the painter yourself.

Gopala Krishna
16th March 2007, 15:37
You can subclass the item and reimplement the paint method, calling the base class with a modified painter rectangle (translate the painter). As for the "static" part, draw it on the painter yourself.
But what about managing bounding rect ? Can you please help me ?

wysota
16th March 2007, 18:09
What about the rect? You have to modify it to include the "static" part. You'll probably want to use QFontMetrics to calculate the size needed.

Gopala Krishna
16th March 2007, 18:26
What about the rect? You have to modify it to include the "static" part. You'll probably want to use QFontMetrics to calculate the size needed.

Ok I will do that. But for testing purpose I used magic numbers. I am attaching the code.
The problem now is I am not able to move the item normally. Whats wrong ?