Hi,
I want to fill a GraphicsItem with a color but not completly i want to fill it based on user choice i.e if user want to fill only 50% of a Item the Item should get filled only partially.
How is this possible
Check the attached image.
Hi,
I want to fill a GraphicsItem with a color but not completly i want to fill it based on user choice i.e if user want to fill only 50% of a Item the Item should get filled only partially.
How is this possible
Check the attached image.
Reimplement the paint routine for the item and paint it properly. What did you try already?
Thanks for reply.
Actually I am reimplementing the Diagram Scene Example. I want to fill only some region of graphics item. I have not found any methods to that, except setBrush which fill complete item.
My aim is to fill continuously from 0 to 100 % of an Item.
How can I do it.
I already told you how. Reimplement the paint() rountine, calculate the shape that is to be filled and use QPainter API to do the drawing, probably using QPainter::drawPolygon().
But I want to retain its original shape.
My answer still stands. And if you want to do it another way then apply clipping to the painter according to the part you want to fill and fill the whole item.
if I impliment in this loop my Item should be filled in 5 loops as in attached image
As you know that in DiagramScene example I have a MainWindow in that DiagramScene on that with mousce click I am placing DiagramItem which is a QGraphicsPolygonItem in that class there is no paint() only setPolygon is there.
So do i have to implement Paint() and if i write my fillItem() in MainWindow then i have to call Item's paint in a loop to get the effact i want.
can u just show me sample code.
Thank u,
regards.
QGraphicsPolygonItem is inherited from QGraphicsItem and hence you can always override the paint function.
You will need to inherit from QGraphicsPolygonItem and reimplement paint function.
In that paint function u can call the base class paint function and then fill the desired area in your class paint function.
If I do so then the Paint Function of the Item is called only once when it is created. Then how can I show the Filling effect on the scene. I fill the Item in a loop with some delay in each filling untill its full.
Thanx for reply, but I am not able to form the paint logic, plz help to to fill item in a loop with 500ms wait.
Bookmarks