Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
FlowLayout uses too much height
JoeAB last edited by
I am trying to use the FlowLayout sample to create a docked panel with 26 same-size buttons. The buttons are positioned OK and also flow properly when the width of the application is changed.
However, the height of the panel remains constant and too large. I left these overridden functions as is, except for diagnostics.
int FlowLayout::heightForWidth(int width) const
int height = doLayout(QRect(0, 0, width, 0), true);
qDebug() << "heightForWidth(" << width << ") ht=" << height;
void FlowLayout::setGeometry(const QRect &rect)
int height = doLayout(rect, false);
heightForWidth is only called once, using the width of roughly one button plus margins. The height calculated is for 26 rows (818 pixels), instead or 2 or 3 rows (105 or 136 pixels).
Is there an easy way to get the FlowLayout to use the calculated height?