2

This question is about the very same problem described in Resize QDialog at a runtime, but the answer there does not fit my needs.

layout()->setSizeConstraint(QLayout::SetFixedSize);

does the trick that the QDialog resizes itself if it's content is changed. But the possibility to resize the dialog manually is lost doing so.

Is there a way to resize a QDialog programatically after some content has been hidden other than setting the main layout's size constraint to QLayout::SetFixedSize? I tried all kind of code, including saving the geometry before showing the additional widgets and re-setting this very geometry after hiding them, but no matter what I do, nothing happens.

Thanks for all help!

Community
  • 1
  • 1
Tobias Leupold
  • 1,512
  • 1
  • 16
  • 41
  • Is the problem that the dialog does not *shrink* after hiding widgets or what? – peppe Jan 30 '17 at 19:50
  • Exactly. That's it :-) Or more general: it silenty ignores all my attempts to set another (smaller) size. – Tobias Leupold Jan 30 '17 at 20:08
  • Did you try changing the layout's size constraint policy after hiding the widgets ? For example to minimum size. – Cristi Feb 01 '17 at 12:26
  • Resizing the dialog to a smaller size is still ignored. – Tobias Leupold Feb 01 '17 at 13:16
  • As in, `dialog->resize(dialog->sizeHint())` ? – peppe Feb 02 '17 at 19:02
  • I saved the original geometry from before showing the hidden widgets in a member variable, and tried to re-set this very geometry after hiding the widgets again. – Tobias Leupold Feb 02 '17 at 22:20
  • Did you ever solve your problem? What did you end up doing? – Burrow Sep 17 '20 at 19:06
  • I think I did, but I don't know anymore which specific case I described here so that I could look into the code. Most probably, I used some QTimer::singleShot(0, [this] { ... }) lambda call to resize the dialog after being sure everything has been drawn and the geometry was updated. – Tobias Leupold Sep 19 '20 at 08:29

0 Answers0