[Development] QTreeView: vertical bar between columns

Arno Rehn a.rehn at menlosystems.com
Tue May 17 17:44:08 CEST 2022

Hi Konrad,

Am 17.05.2022 um 17:36 schrieb Konrad Rosenbaum:
> On 17/05/2022 14:58, Volker Hilsheimer wrote:
>> As mentioned in the JIRA ticket: perhaps a treeview, which is designed 
>> to show rows of data, not cells of data, is not the right UI component 
>> for the job, and the problem you try to solve seems very application 
>> specific (I’m not aware of a native tree view on macOS or Windows that 
>> provides a strong visual border between columns; ie macOS’s folder has 
>> a specific Column view mode for that). Override the delegate and make 
>> each cell stand out more if you want, or override the view’s 
>> paintEvent and render whatever you want after the view is done. I 
>> don’t think this belongs into QTreeView. 
> It is a really common requirement - if you have complex hierarchical 
> models then sometimes you have no choice but to display parts of the 
> hierarchy in a table. Unfortunately QTableView is not able to view trees 
> and QTreeView is sub-optimal for viewing tables. What is required is a 
> widget or mode of a widget that combines both abilities. I've had this 
> requirement in almost all of my projects that try to visualize and 
> interact with complex data analyses.

Sounds like QTableView is really what you want, but your model is not a 
table model. You can implement a proxy model that exposes a subtree of 
your tree model (possibly also hiding any remaining children). This 
subtree should be usable with QTableView just fine.

I've implemented such a SubtreeProxyModel for our own needs and it works 
nicely (it's not primarily used for QTableView, though).


Arno Rehn
Tel +49 89 189 166 0
Fax +49 89 189 166 111
a.rehn at menlosystems.com

Menlo Systems GmbH
Bunsenstrasse 5, D-82152 Martinsried, Germany
Amtsgericht München HRB 138145
Geschäftsführung: Dr. Michael Mei, Dr. Ronald Holzwarth
USt.-IdNr. DE217772017, St.-Nr. 14316170324

More information about the Development mailing list