Why do my QListWidgetItems break to the next line before reaching the edge of the window?

46 Views Asked by At

I'm creating an image grid in Qt as seen in these screenshots:

One row

Row break

The problem occurs while resizing the window. The last image breaks onto the next row before it touches the edge of the window. This is even more noticeable when the items are larger. Is it possible to change some padding/marging/spacing to allow the grid to bump into the edge, then break to the next row?

I've tried using this, but it doesn't work:

#listWidget{
    background-color: green;
    padding-top: 5px;
}
#listWidget::item{
    background-color: red;
    margin:  0px;
    padding: 0;
}

As a side question, I am able to remove the item padding, as seen with the red background, by using this stylesheet:

#listWidget::item{
    padding: -1px -3px -4px -4px;
}

Is there a better way to remove the padding from individual items so they are right next to each other? Why doesn't margin: 0; padding: 0; work?

0

There are 0 best solutions below