Pergunta

I have a QWidget which have an horizontal layout which holds a QScrollArea. When I add a widget to the QScrollArea, I change the maximum size for the container QWidget with:

this->setMaximumSize(newWidget->maximumWidth(), newWidget->maximumHeight());

The maximum size is well changed but the maximize button doesn't work anymore. I can change the size of the widget with the mouse, but not with the maximize button.

If I set the maximum size with a higher value, for example:

this->setMaximumSize(newWidget->maximumWidth() * 2, newWidget->maximumHeight() * 2);

The maximize button works well.

Thanks in advance.

Foi útil?

Solução

You have set the maximum size to be less than that of your desktop size. So when you try to maximise the widget, you are asking the widget to go beyond the maximum size you set it - so it ignores you.

Presumably newWidget->maximumWidth() * 2 works because that figure is larger than your desktop size.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top