PDA

View Full Version : getting QGraphicsView to resize



MrGarbage
22nd January 2008, 02:42
Hi,

I've recently introduced a QGraphicsView into one
of my dialogs replacing what was previously a layout
of many buttons. The response time of the dialog is
much improved, however I am not getting the resizing
behaviour I need.

In some cases I need to hide the lower half of the
controls. As they are layed out together when I hide
the controls and the respective QGraphicsItems that
are contained in the lower portion of the QGraphicsView,
I want the QGraphicsView to resize down to the vertical
size that is only necessary to show the non hidden
QGraphicsItems.

However the QGraphicsView always stays the same size.
I have tried various combinations of sizePolicy
in QT Designer.

How can I accomplish this?

Thank you.

Mark

Gopala Krishna
22nd January 2008, 03:49
Its not trivial to get it done using layouting or size policies alone. May be you can do something like the below after hiding the controls; And you might also need spacers and also you might need to experiment again with sizepolicies, minimum size...


view->resize(scene->itemsBoundingRect().size());