[Qt-interest] QTableView 2 rows inside every row

Kaleb Pederson kaleb.pederson at gmail.com
Tue Apr 21 05:43:35 CEST 2009


On Mon, Apr 20, 2009 at 11:36 AM, Linos <info at linos.es> wrote:
> Hello,
>        i need to create a tableview where in every row you can see an information for
> the complete row but later to define the units for every size make a division
> inside the row, like this:
>
> Header:         Model | Description        | Price   |                 Size / Qty
> ROW:            15415 | Beautiful Shoes |  15.50 | 9.5  10  9
> SAME ROW:             |                              |             |   5     3   0
>
> I dont know how represent this exactly with chars but i think you can see the
> idea, the row should have a height bigger than normal to contain the division
> and the columns Model, Description and Price should be Center aligned in the
> row. The size should be header like but i suppose i can get the effect simply
> changing the colors.
>
> What would be the better way to do this with qt? Thanks.

That will depend on some other needs.  Do you need to be able to
change the second displayed row if the user clicks on a particular
element?  Do you need to be able to select certain columns of both
rows, etc.?

You can draw just about anything you like for the display using an
item delegate.  See QAbstractItemDelegate and QItemDelegate.  It's not
really intended to be used that way, but there's nothing really
preventing you from using it as such.

Another thought is to create a Proxy model that maps one physical row
to multiple logical rows.  The delegate could then check to see if you
were on an even or odd row, or a specific role, to know how things
should be drawn, if you needed something special.  This is probably
your best option.

I hope that gives you enough to go on.

--Kaleb




More information about the Qt-interest-old mailing list