[Development] QTreeView: vertical bar between columns

Konrad Rosenbaum konrad at silmor.de
Tue May 17 17:36:31 CEST 2022


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.

Having a "cell border" setting for a tree view, a derived view class or 
delegate class for that purpose would make things considerably easier 
for those among us wrangling complex data into expert GUIs. ;-)

Last time I tried to solve this problem I derived from 
QStyledItemDelegate and got something that kind of works, but looks 
ugly. I would have greatly appreciated a simple setting or ready made 
class that draws cell borders in tree views in a way that is consistent 
with the style.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220517/cada071f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220517/cada071f/attachment.sig>

More information about the Development mailing list