> On 17 May 2022, at 12:47, Laszlo Papp <[email protected]> wrote:
> 
> 
> 
> On Tue, May 17, 2022 at 11:34 AM André Somers <[email protected]> wrote:
> 
> 
> On 17-05-2022 12:12, Laszlo Papp wrote:
>> 
>> 
>> On Tue, May 17, 2022 at 11:01 AM André Somers <[email protected]> wrote:
>> Hi,
>> 
>> On 16-05-2022 23:26, Laszlo Papp wrote:
>> > Hi,
>> >
>> > Was just wondering if it was okay to add a property for drawing 
>> > vertical bar between columns in the body of the QTreeView. Our 
>> > customer has requested this as otherwise it was challenging to 
>> > visually separate the columns.
>> >
>> > It looks like jpn had a fairly trivial paintEvent implementation for 
>> > this, so should not be hard to add: 
>> > https://www.qtcentre.org/threads/8684-how-to-show-vertical-lines-between-colums
>> >
>> > Kind regards,
>> > László
>> >
>> Doesn't this belong in the style instead?
>> 
>> If you ask me, as much as QHeaderView's vertical bar. It is the same thing, 
>> just for the body. And that is also in Qt proper.
> I'd argue both belong in the style actually.
> 
> 
> Sure, but that should have been argued long time ago (15+ years) when it was 
> added to QHeaderView in my opinion. Now, I feel like consistency is better 
> than ideal inconsistency.


QHeaderView renders each section using QStyle:

style()->drawControl(QStyle::CE_Header, &opt, painter, this);

(in QHeaderView::paintSection). Even the empty space is painted using the style:

style()->drawControl(QStyle::CE_HeaderEmptyArea, &opt, &painter, this);

(in QHeaderView::paintEvent, after a call to paintSection for each section).


The other itemviews paint their items using a delegate, and the default 
QItemDelegate uses the style for some things, e.g. check marks and tree 
decorations, and otherwise provides a virtual interface for the various aspects 
of a cell. Plus the general paint() method to do per-item custom painting.

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.


Volker


_______________________________________________
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to