How to get identation width of QTreeView from QStyle

177 Views Asked by At

I have pre-existing code which has a tree view like appearance but doesn't actually use QTreeView (uses QListWidget with custom paint).

I am tasked to add the indentation between the parent and child objects, but I can't able to find how to get the style default indentation width from QStyle. The program has to run on a variety of os and allow to use custom stylesheets. So it's important to get this option from QStyle.

Regards.

1

There are 1 best solutions below

1
unknown.prince On BEST ANSWER

found this in qt sources

have to use QStyle::pixelMetric with QStyle::PM_TreeViewIndentation
inside your widget's procedure

ident = style()->pixelMetric(QStyle::PM_TreeViewIndentation)