开发者

Individual QTreeWidgetItem indentation

开发者 https://www.devze.com 2022-12-21 15:26 出处:网络
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 witho

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?


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 !


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号