How to customize the display of a QListView

让人想犯罪 __ 提交于 2019-12-11 07:24:51

问题


I have implemented a list of users in my Qt program, using the model/view principle of Qt. My QListView displays a subclass of QAbstractListModel and so far this works just fine.

Now I would like to customize the display of my user list (display the name on several line, add IP information, and so on: not really relevant, I just want something really custom).

I couldn't find anything in the Qt documentation regarding this: what are my options ?

Note: The items in the list do not need to (can't) be modified, if this can help.

Thank you.


回答1:


You need to create a new item delegate class to handle the painting. Here is a good answer to a similar question.



来源:https://stackoverflow.com/questions/3247030/how-to-customize-the-display-of-a-qlistview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!