QListWidget rows overlaping each other

Viewed 195

First of all I am apologizing for my English in advance. I am trying to display a custom widget in a QListWidget, but when more than one row is added, they are displayed on the same spot.

My application desing
(source: minespeed200.de)

Settings of the QListWidget

    alternateingRowColors:true
    movement:Static
    isWrapping:false
    resizeMode:adjust
    layoutMode:singePass
    spacing:1
    viewMode:listMode
    

i've already tried all of the possible settings for this values. if there is another importent one i've missed (i am fairly new to Qt) please tell me. Also the row colors seem to overlap too (the picture of my application below has 2 rows added), what tells me, that not only the widget's but the row's are overlapping each other entirely.

My custom widget desing
(source: minespeed200.de)

The resulting overlap of rows
(source: minespeed200.de)

I am adding the rows with this code:

item=new QListWidgetItem();
QSize size(this->width(),this->height());
item->setSizeHint(size);
list->addItem(item);
list->setItemWidget(item,this);

Inside of the constructor of my custom widget class.

2 Answers

The issue was that i left the gridSize of my QListWidget at it's default value and the y component had to be set to the height of my widget i was displaying. Adding:

    list->setGridSize(QSize(0,this->sizeHint().height()));

fixed it.

Related