如何自定义QListView的显示 [英] How to customize the display of a QListView

查看:2004
本文介绍了如何自定义QListView的显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在 Qt 程序中使用 Qt 原则实现了用户列表, / code>。我的 QListView 显示 QAbstractListModel 的子类,到目前为止这个工作很好。

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.

现在我想自定义我的用户列表的显示(在几行显示名称,添加IP信息,等等:不真正相关,我只是想要一些真正的自定义)。

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).

我在 Qt 文档中找不到任何有关这个的文档:我的选项是什么?

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.

谢谢。

推荐答案

您需要创建一个新的 item delegate 类来处理绘画。 此处是类似问题的良好答案。

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

这篇关于如何自定义QListView的显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆