1
votes

I am now trying to resize a qgraphicsview to a preffered size: I am using layouts:

this->layout()->addWidget(&qtview);

I have layouts everywhere, so thet the size of my main widow is adjusted depending on its contents.

If I use:

qtview.setMinimumWidth(500);
qtviewSetMinimumHeight(500);

Then my view is scaled to the given size, but I am not able to shrink the main window. (which makes sense as I set a minimum soze)

I would like to tell qt my preferred (not minimum or maximum) size for the view, letting the view use scrollbars when needed (i.e. if the preferred size does not fit in my screen), or letting qt have a smaller view than my preferred size if the scene is smaller than my view, (or enlarge the scene to fit the view in this case)

I am searching for something looking like an hypothetical method setPreferredWidth().

What can I do to get this behaviour?

1

1 Answers

0
votes

It sounds like you're looking for the QGraphicsView function setSizePolicy: -

setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));