Why QFrame does not resize on QgraphicsScene?
Hi,
I have a QGraphicsScene to which I would like to add a QFrame. I'm doing so by calling the addWidget function of the QgraphicsScene class.
On the created QFrame I've added a grid layout which contains QGraphicsWidget classes.
Why the QFrame always keeps its size? If I have a small number of elements in the layout it fits well inside the QFrame but
as soon as I add too much elements the widgets go outside of the boundaries of the QFrame. (I can stell see them because the QGraphicsView scrolls but outside of the frame)
Actually my goal is the having a border around my grid layout.
Do you have any ideas?
Thanks
Re: Why QFrame does not resize on QgraphicsScene?
That sounds like a broken approach, so maybe it is better if you describe what your goals are.
If you add a container widget like a QFrame you would add widgets to it, not graphic items. A container widgets knows nothing about graphics items, it only deals with child widgets.
Cheers,
_
Re: Why QFrame does not resize on QgraphicsScene?
Thank you for your response.
I have a QGraphicsGridLayout with objects classes inheriting from QGraphicsWidget. My goal is to have a rectangle as a border around my QGraphicsGridLayout
Thanks!
Added after 51 minutes:
I thought another solution may be to inherit from QGraphicsWidget. Then set my grid layout on. Finally to override the paint function by calling the base class paint function QGraphicsWidget::paint() and then drawing a rectangle defined by the bounding rect.
Re: Why QFrame does not resize on QgraphicsScene?
Quote:
Originally Posted by
Manuka
then drawing a rectangle defined by the bounding rect.
Or use a QGraphicsRectItem
Cheers,
_