[SOLVED] How to paint a QGraphicsItemGroup object?
General and Desktop
2
Posts
1
Posters
1.2k
Views
1
Watching
-
wrote on 24 Sept 2015, 04:25 last edited by xtingray
Hi,
Currently I am programming a basic dialog to visualize a QGraphicsItem object. Using the paint() method is working pretty well with the single items:QGraphicsItem *item; ... item->paint(painter, option, widget);
My problem occurs when I try to visualize a QGraphicsItemGroup object, I don't get any error message but only an empty area, if I try this code:
QGraphicsItemGroup *group; ... group->paint(painter, option, widget);
So, I would like to know what is the right way to paint a group in this context? Thanks.
-
wrote on 25 Sept 2015, 02:06 last edited by
Finally, I found a nice way to visualize a QGraphicsItemGroup in an accurate way. Here is the code:
if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(item)) { foreach (QGraphicsItem *child, group->childItems()) child->paint(painter, option, widget); } else { item->paint(painter, option, widget); }
I hope this trick can be useful for somebody else ;)
1/2