View Full Version : QListView icon size and align

5th June 2014, 04:33
Hi all,
I'm working on a content browser, I have a QListView sets to icon mode.
That works fine but the problem is how changes the item size ?
Another problem is items are not aligned, a solution exists ?
Thanks for the help


m_DetailTree->setMovement( QListView::Static );
m_DetailTree->setGridSize( QSize( 60, 60 ) );

That align but the size of the item in the grid cell doesn't take all the cell space, it's fixed size, a solution exist ?
I tried :

m_DetailTree->setGridSize( QSize( 80, 80 ) );
m_DetailTree->setIconSize( QSize( 80, 80 ) );
m_DetailTree->setUniformItemSizes( true );

setIconSize has no effect, maybe a bug of Qt.

5th June 2014, 09:22
If an icon is smaller than the set icon size then it is not upscaled. Use a larger icon.

5th June 2014, 14:56
Ok, then a last question about that : Is it better to have large icon for icon view and downscale for the tree or have two icons ?

5th June 2014, 15:34
QIcon can hold more than one size of an icon and Qt mechanisms can ask QIcon for a pixmap with a given size thus it is better to have two pixmaps stored in one QIcon that will choose the pixmap for you.

5th June 2014, 16:02
Is it possible to find an icon filepath from stylesheet or that demand a custom parser ?

5th June 2014, 16:24
There is no interface for accessing the stylesheet. It is an opaque string, if you want it parsed, you have to do it yourself.