在 Qt 中:
QVBoxLayout *layout = (QVBoxLayout*)this->layout();
printf("Before: %d %d\n", this->height(), layout->totalSizeHint().height());
QWidget *widget = new SubWidget();
layout->insertWidget(0, widget);
this->updateGeometry();
this->adjustSize();
this->update();
this->repaint();
printf("After: %d %d %d\n", this->height(), layout->totalSizeHint().height(), widget->height());
问题是尽管小部件高度非零(在我的情况下约为 400),但我在之前和之后得到相同的数字。为什么?