So mine question is: is there any way to make listWidgetItem occupy as much space as it needs (apposed to fixed size)? I use customised widget as items (2 labels + picture + Multi-line lable).
Printable View
So mine question is: is there any way to make listWidgetItem occupy as much space as it needs (apposed to fixed size)? I use customised widget as items (2 labels + picture + Multi-line lable).
Try using QListWidgetItem::setSizeHint().
Well.. the maximum size of hints is the same... I tried to compine their heights using, for example:
name = new QLabel("Name");
int asd;
asd += int->height();
but all the labels have the same height, so i cannot define which items should be bigger, and which should be smaller...
The size hint is computed by widget and depends on their content.
This code works
Code:
void Widget::on_computeButton_clicked() { int maximumSizeHint = 0; QList<QLabel*> labels = this->findChildren <QLabel*> (); 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); }
The output is:
Code:
label sizeHint.height = 13 label_2 sizeHint.height = 13 label_3 sizeHint.height = 39 Maximum sizeHint height = 39
The widget is in attachment:Attachment 5870