What is the correct way to customize Icon and Text position of items in a QListView?

Posted by petermcg on Stack Overflow See other posts from Stack Overflow or by petermcg
Published on 2011-01-17T01:52:09Z Indexed on 2011/01/17 8:53 UTC
Read the original article Hit count: 145

Filed under:
|

I'm using C++ and Qt's (4.6) model/view framework and wondering what is the correct way to change the display of items in a QListView or a class derived from QListView from:

alt text

to:

alt text

I'm not concerned about the sort order or Flow, I'm interested in the best way to correctly position the text to the right of the icon.

If this can only be done by writing a custom QStyledItemDelegate that's totally fine, I want to rule out whether this is the correct approach or whether it's best to look at setLayout or similar, example code would help.

The example application I'm looking at is the 'interview' example from qtdemo which amongst other things displays icons and text in a QListView.

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt