PDA

View Full Version : How can i set the display range of a QGraphicItemGroup?



mrmuto2
21st February 2018, 05:42
I want to just show the display area.

To do that, I have tried the override the QGraphicsItemGroup::boundingRect(). However, nothing have happened. And i find this in QT docs, maybe this is the reason why doesn't work.

The boundingRect() function of QGraphicsItemGroup returns the bounding rectangle of all items in the item group.

Also, i know i can change the size of QGraphicsView to make it work. However i put the View as CentralWidget, as i also need to display other object in the View, i can not change the size of the View.

How can i set the display range of a QGraphicItemGroup?

wysota
25th February 2018, 08:22
Not sure what you mean, do you want to clip contents of an item? After setting boundingRect() for an item (e.g. your group) you can set the QGraphicsItem::ItemClipsChildrenToShape flag on it to make it clip its children to its own shape.

As for the view, have a look at QGraphicsView::fitInView().