We still have no idea how the boundingRect() for your item is defined. What do you set it to?
We still have no idea how the boundingRect() for your item is defined. What do you set it to?
I have not redefined the 'boundingRect' method !
I know but you are calling setRect() somewhere which defines the bounding rect. By the way, why are you manipulating the animation in the function related to drawing your item?
Yes,
I call : setRect(0, 0, 90, 90); in the "initializeNode()" method.
Because, when the item is selected I want to animate a "circle" around the item... a simple color transition... that will highlight the selected item.By the way, why are you manipulating the animation in the function related to drawing your item?
Try enabling cache for your items. However this will surely break your already broken animation code. I wouldn't expect miracles performance wise if you are changing the highlight color constantly. Maybe making the highlight a separate item would help more.
paint() routine is for painting, not for starting animations. Manipulate the animation when the selection value changes. And set the loop count to infinite instead of manually checking the state of the animation every frame and restarting it when it finishes its course.Because, when the item is selected I want to animate a "circle" around the item... a simple color transition... that will highlight the selected item.
Thanks,
1) I used setCacheMode(QGraphicsItem:eviceCoordinateCache); for caching... Notice I also need anti-aliasing !
2) Sure, I can start the animation somewhere else... but it would'nt change anything to performance ! (I have just try of course) ;-)
I don't see how anti-aliasing is relevant here. I would rather use ItemCoordinateCache.
If you change the item every frame, then caching only makes your app slower since it has to be regenerated again and again. If you move the animation outside your item then at least the item itself can be cached properly and will not execute your quite complex code on each frame of the animation. All this does not change the fact that putting animation controlling code into a paint routine is simply wrong.2) Sure, I can start the animation somewhere else... but it would'nt change anything to performance ! (I have just try of course) ;-)
Bookmarks