单独的 QTreeWidgetItem 缩进

发布于 2024-08-23 13:55:24 字数 125 浏览 2 评论 0 原文

是否可以对 QTreeWidget 中的项目进行单独缩进?

具体来说,我有一列包含文本、图标和其中一些复选框。没有复选框的项目会向左移动,因此图标和文本的缩进不会与其他项目内联。如果可能的话,可以用隐藏的复选框来修复吗?

Is it possible to have individual indentation of items in a QTreeWidget?

In specific, I have have a column containing both text, icon and for some of them a CheckBox. The items without a CheckBox gets shifted to the left so the indentation of the icon and the text is not inline with the others. Could maybe be fixed with a hidden CheckBox if that is possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

两个我 2024-08-30 13:55:25

您可以尝试在 QTreeWidget::itemWidget() 返回的小部件上使用 QWidget::setContentMargins()

You can try using the QWidget::setContentMargins() on the widget returned by QTreeWidget::itemWidget().

稳稳的幸福 2024-08-30 13:55:24

也许使用委托会给你一个很好且正确的实现。您将有机会重新实现 Paint() 和 sizeHint() 方法,因此,选择绘制 QTreeWidgetItem 的方式...

更多文档:http://doc.trolltech.com/4.6/model-view-delegate.html

示例:http://doc.trolltech.com/4.6/itemviews-pixelator.html

希望有帮助有点!

Maybe the use of Delegates will give you a nice and proper implementation. You'll have the opportunity to re-implement the paint() and sizeHint() methods, and therefore, choose the way your QTreeWidgetItem are being drawn...

More documentation here : http://doc.trolltech.com/4.6/model-view-delegate.html

An example : http://doc.trolltech.com/4.6/itemviews-pixelator.html

Hope it helps a bit !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文