Simple question, but I can't seem to get it right.
I have a QDialog
containing a QScrollArea
, which contains a QVBoxLayout
. I want the dialog to be resizable vertically, but only up to the point where the scrollbars disappear, and the layout is shown in full.
I have tried QDialog::setMaximumHeight(int)
with various parameters, such as size hints, but nothing has worked so far.
Based on the given description I suggest you to use QDialog::setMaximumHeight
with QScrollArea::widget
's sizeHint().height()
as an argument like this:
setMaximumHeight(widget->sizeHint().height());
Take a look at the example I have prepared for you:
https://github.com/scopchanov/SO-MaxDialogHeight
Let me know if you need help adapting it to your particular task.