Subject: Re: QTreeView setFirstColumnSpanned?

Linus Torvalds torvalds at linux-foundation.org
Sun Jun 9 13:24:52 PDT 2013


On Sun, Jun 9, 2013 at 11:03 AM, Amit Chaudhuri
<amit.k.chaudhuri at gmail.com> wrote:
>
> QTreeView has a protected virtual method for drawing a row.  I've not had
> time to look at the code for that in any detail, but it sounds like an
> invitation to sub-class and get any row specific behaviour we wish to have.
>
> So we might consider something like this:
>
> - sub-class QTreeView

We already do this (DiveListView).

> - re-implement drawRow

Ok, I did that, easy enough.

> - in our drawRow, test ( isTrip() )

Done.

> - compose the custom string we want to display from trip data "fields"

Done (ok, for now I just take the name).

> - display trip in our custom manner

.. but this is a *bitch*.

Why? The drawRow() function seems to be complex as hell. It has to
know all the insane private details of the QTreeView. It needs to do
all the background color selection (possibly alternating), the "is
this row selected" stuff, yadda yadda. Looking at the sources of the
*normal* drawRow(), this is very painful.

But maybe there is some shortcut that I don't know about.

> - else do the usual - 'cos it's not a trip

Well, that's the trivial case.

Anyway, the appended patch does everything *except* for the actual
drawing of the string. Which looks insanely complex to somebody that
doesn't know Qt. Can anybody fill in the missing blanks (literally:
there is a comment like

     /* Draw 'trip->name' here ! */

but since it doesn't do it, the trip rows end up being blank).

                   Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 1560 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130609/63bd9b0a/attachment.obj>


More information about the subsurface mailing list