PDA

View Full Version : Display icons with text on a listwidget uniformly



g3ven
14th April 2016, 10:56
Hi,

I add thumbanil images to a list widget and display the same in an icon mode along with text. However, due to the aspect ratio of the thumnails , i get the images up and down and not in a uniform line. Could you please help me ? I have attached the image of how it is now and how i want it to be

HOW IT IS NOW
11892

HOW IT SHOULD LOOK
11893

Snippet of how i add the files to the list widget



// list the files in the list widget in the icon mode
for (int i=1; i<imgList.size(); ++i)
{
QSize grid(150,150);
QString imgPath = scaledDirPath.absoluteFilePath(imgList[i]);
ui->FilesList->setMovement(QListWidget::Static);
ui->FilesList->setViewMode(QListWidget::IconMode);
ui->FilesList->setWordWrap(true);
QString origImageName = (imgList[i].remove("_scaled", Qt::CaseSensitive));
QListWidgetItem *item = new QListWidgetItem(QIcon(imgPath),origImageName);

item->setTextAlignment(Qt::AlignBottom);

ui->FilesList->setGridSize(grid);

ui->FilesList->addItem(new QListWidgetItem(QIcon(imgPath),origImageName));

}

Any help is appreciated

Thanks
Gayathri