Qt为Qtreeview中的子项目设置不同的高度
我目前正在通过样式表定义 QTreeView 中项目的高度,
QTreeView {
background: palette(window);
color: palette(text);
border: none;
}
QTreeView::item {
height: 40px;
padding-top: 0.5ex;
padding-bottom: 0.5ex;
margin: 2px;
}
这样,树中的所有项目都将具有相同的高度。是否可以为孩子定义不同的身高?
I'm currently defining the heights of items in a QTreeView via a stylesheet
QTreeView {
background: palette(window);
color: palette(text);
border: none;
}
QTreeView::item {
height: 40px;
padding-top: 0.5ex;
padding-bottom: 0.5ex;
margin: 2px;
}
With this, all items in the tree will have the same height. Is it possible to define a different height for the children?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否可以通过样式表来完成。实现此目的的正常方法是覆盖
QAbstractItemModel::data< /code>
并让它返回与
Qt::SizeHintRole
数据角色关联的特定值。I'm not sure if this can be done via a stylesheet. The normal way to achieve this would be to override
QAbstractItemModel::data
and have it return specific values associated with theQt::SizeHintRole
data role.