How do I auto-adjust the size of a QDialog depending on the text length of one of its children?
Automatic solution:
Use layouts and set size policies to QSizePolicy::Expanding
. In QtDesigner, once all your children are placed on your QDialog, then click on the Adjust Size button next layout ones. Your QDialog will be automatically resized at runtime.
Manual solution:
The QWidget
class has a method adjustSize
that resize the QWidget to fit its content. Just call it when all children are set.