Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTreeView column sizes



  • Standard implementation of QTreeView draws elements so that they have a table layout. As a result i get unnecessary spaces between elements, when i expand branches(example). How do I get QTreeView to draw rows without spaces between the elements, as if they are one solid element(example)?


  • Moderators

    You could make the colored dots to be returned for Qt::DecorationRole of the first column in your model, instead of being a separate column. this way they become part of the item and it gets indented as a whole.



  • The thing is, that i need this dots to be separate items, since they are used as clickable buttons. I tried to inherit from QTreeView and override drawRow, but when i do that, i need to override visualRect, indexAt and some other methods too, and that's realy inconvenient. Is there another way to reach my goals with QTreeView , or do i need to inherit from QAbstractItemView, and implement this kind of TreeView myself?