Hi all
I use a QListWidget to show a custom widgets that include a label and checkbox.
But sometimes, these custom widgets didn't alignment to a baseline, like blow picture
qlistwidget_align_issue.jpg
And you can see there is a light-blue block above the widget that doesn't align.
here is the code i insert the custom widget to qlistwidget
CustomWidget*cgv = new CustomWidget();
cgv->setChecked(cellPassed[j].checked); // set checkbox state
cgv->setImage(QPixmap::fromImage(qimg)); // set the image show by QLabel
QString itemName = "block" + QString::number(i); // assign a name to the item to search it by name.
QListWidgetItem *item = new QListWidgetItem(itemName, ui->listWidget);
ui->listWidget->addItem(item);
item->setSizeHint(cgv->size());
ui->listWidget->setItemWidget(item, cgv); // insert the custom widget to the current item.
I try to set Qlistwidget's resize mode to batched and set batchsize to 1, it looks work for this issue,
but batchsize 1 is not good for display while resize the QListWidget content.
does anyone have any comment for this issue?
thanks a lot.
BR, Titan.Chen
Bookmarks