I would like to adjust a QListView's width according to its content to let every item visible. The list is like:
...
setFlow(QListView::LeftToRight) ;
setLayoutMode(QListView::Batched);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAutoScroll(false);
setUniformItemSizes(true);
setResizeMode(QListView::Adjust);
...
I tried different QSizePolicy and got really confused.
This switch:
turns on some optimizations of the QListView. Seems like the optimized code does not calculate the layout when qlistview is resized. Try setting setUniformItemSizes(false) and your qlistview should adapt to the item sizes.