PDA

View Full Version : How to render an item of graphicscene with two different colors at two scenewiewers?



tonnot
2nd September 2011, 09:19
And, how could I make the next :

I have a Line. I add it to the items of the scene.
I have two sceneviewers, the first one are going to render the line in red , the second in green.
But I only have a line with one Qpen property.....

Is there any solution to this ?
Thanks.

mmm
I think that the way is to have a custom item class with Paint overloaded ?
But it would exist any faster-direct way ?

wysota
2nd September 2011, 09:26
Yes, there is alas a dirty one. Have a look at the last argument of QGraphicsItem::paint().

tonnot
2nd September 2011, 11:58
Why 'dirty one.' ??

So, the initial approach can be create graphicsitems with their paint overloaded. But in this case I have to rewrite by hand the paint mechanism.

So, after I have to look at the diagramscene example, I have this question:
How can (can it ?) I create a QGraphicsItem and inside it say: you are a QGraphicsLineItem ? My idea is avoid to rewrite the paint neede code.
Is it possible ?

Also... I dont remember if exists something to do 'paint yourself everithing you have to paint' inside a paint??

Thanks.

wysota
2nd September 2011, 15:29
Why 'dirty one.' ??
Because the pointer can be null.

tonnot
2nd September 2011, 17:28
And.... about the other questions ?

How can (can it ?) I create a QGraphicsItem and inside it say: you are a QGraphicsLineItem ? My idea is avoid to rewrite the paint neede code.
Is it possible ?

Also... I dont remember if exists something to do 'paint yourself everithing you have to paint' inside a paint??
Thank you for your time-.

wysota
2nd September 2011, 23:20
If I wanted to answer the other questions, I would have. If you're lazy enough not to do anything by yourself then I'm lazy enough to pick which questions I want to answer and which not. This is a "Qt Programming" forum where you ask advanced questions and not a "Help me, I don't know how to program" forum. I have answered your advanced question. I'm fed up with spoon feeding you with knowledge. Consider this a kick in your butt that tries to force you to learn and understand programming before you start doing any advanced stuff. Try to solve your problems with means you understand and those that you come up with on your own.