1 Attachment(s)
Qt: Space between individual cells in QTableWidget
(Using Qt 5.5.1 on Windows 8.1)
I have a table displaying images selected by the user.
I know their are many other ways to display multiple images on a GUI, but I'm new to Qt, so I didn't understand how to use QGraphicsView and found the following to be the easiest way.
But this forms a table in which images are not separated. I want some space b/w them. See how the next images starts right where the first ends.
Attachment 11684
How can I do it so that next image starts after leaving some space?
Code:
dialog.setNameFilter(tr("Images (*.jpg)"));
int maxCol = 3;
int maxRows = all_filenames.size() / maxCol;
ui->tableWidget->setColumnCount(maxCol);
ui->tableWidget->setRowCount(maxRows);
int remainder = all_filenames.size() % maxCol;
if (remainder != 0)
{
maxRows +=1;
}
ui->tableWidget->horizontalHeader()->setDefaultSectionSize(200);
ui->tableWidget->verticalHeader()->setDefaultSectionSize(200);
if(all_filenames.isEmpty() == 0)
{
for( int i = 0; i < all_filenames.size() ; ++i)
{
map = map.scaled(200,200,Qt::IgnoreAspectRatio,Q::FastTransformation);
item->setCheckState(Qt::CheckState());
item->setBackground(brush);
ui->tableWidget->setItem(j,k,item);
k++;
if ( k == maxCol )
{
j++;
k = 0;
}
}
}
Re: Qt: Space between individual cells in QTableWidget
You set the image size to exactly the same size as the cell size.
Have you tried making the images slightly smaller than the cell size?
E.g. 180x180?
Cheers,
_