[Qt-interest] Using QGraphicsLayouts inside QGraphicsWidgets

Sean Harmer sean.harmer at maps-technology.com
Mon Jun 27 11:38:06 CEST 2011


On Monday 27 June 2011 11:24:26 Schimkowitsch Robert wrote:
> In the constructor initialisation list, I initialize my LinearLayout
> member thus:
> m_Layout(this)

Surely that won't work. Did you mean this?

m_layout( new QGraphicsLinearLayout( this ) )

> Of course, the layout itself will recognize when one of it's layout
> items changes.
> The question for me was how that information gets to my ButtonBar, so an
> outer layout seeing my ButtonBar as one of it's LayoutItems will
> invalidate itself.
> 
> Are you implying that telling the layout my ButtonBar is its parent will
> be enough for the invalidation to propagate?

Yes. The QGraphicsWidget and QGraphicsLayout classes take care of propagating 
the change in size hints all the way up the widget/layout hierarchy. ALl you 
have to do is to set that hierarchy up by setting layouts on widgets and 
widgets into those layouts in whatever fashion suits your application. Then 
call updateGeometry() in your widgets when their size hints change. The 
framework does the rest.

Cheers,

Sean



More information about the Qt-interest-old mailing list