如何在Qt中自定义列表视图
我想在 Qt 中自定义列表视图,任何人都可以为我提供一些示例或提示来说明如何做到这一点吗?我是 Qt 新手。
I want to customize a listview in Qt, can anyone provide me some example or hints of how to do it? I am new to Qt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将样式表应用到您的
QListView
。请查看此处获取以下 Qt 文档使用样式表自定义
QListView
。You can apply stylesheet to your
QListView
.Check out here for the Qt documentation of customizing
QListView
using stylesheets.如果您使用标准项目模型或 QListWidget(或使用 QStandardItem 的任何其他模型),则可以使用 setData 设置项目的外观属性。
因此,以下内容将向列表小部件添加一个红色项目:
有关工作代码示例和更详细的说明,请参阅:http://ynonperek.com/qt-mvc-customize-items
If you're using a standard item model or a QListWidget (or any other model that uses QStandardItem), you can set appearance properties on the items using setData.
So, The following will add a red item to a list widget:
For a working code example and more detailed explanation, please see: http://ynonperek.com/qt-mvc-customize-items