Qt QHBoxLayout percentage size
问题 How can I maintain an aspect ratio between two QHBoxLayouts? For instance I want a QHBoxLayout to be one third of the entire window width and the other to be two thirds of the entire window width: How can I achieve this? I tried messing with the size hints of the controls in them but that didn't work out 回答1: void QSizePolicy::setHorizontalStretch(uchar stretchFactor) Example: QHBoxLayout* layout = new QHBoxLayout(form); QWidget* left = new QWidget(form); QSizePolicy spLeft(QSizePolicy: