The size hint is computed by widget and depends on their content.
This code works
void Widget::on_computeButton_clicked()
{
int maximumSizeHint = 0;
QList<QLabel*> labels = this->findChildren <QLabel*> ();
Q_FOREACH (QLabel* lab, labels
) { int itemp = lab->sizeHint ().height ();
qDebug ("%s sizeHint.height = %d", qPrintable(lab->objectName ()), itemp);
if (itemp > maximumSizeHint)
maximumSizeHint = itemp;
}
qDebug ("Maximum sizeHint height = %d", maximumSizeHint);
}
void Widget::on_computeButton_clicked()
{
int maximumSizeHint = 0;
QList<QLabel*> labels = this->findChildren <QLabel*> ();
Q_FOREACH (QLabel* lab, labels) {
int itemp = lab->sizeHint ().height ();
qDebug ("%s sizeHint.height = %d", qPrintable(lab->objectName ()), itemp);
if (itemp > maximumSizeHint)
maximumSizeHint = itemp;
}
qDebug ("Maximum sizeHint height = %d", maximumSizeHint);
}
To copy to clipboard, switch view to plain text mode
The output is:
label sizeHint.height = 13
label_2 sizeHint.height = 13
label_3 sizeHint.height = 39
Maximum sizeHint height = 39
label sizeHint.height = 13
label_2 sizeHint.height = 13
label_3 sizeHint.height = 39
Maximum sizeHint height = 39
To copy to clipboard, switch view to plain text mode
The widget is in attachment:image.PNG
Bookmarks