Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, May 2007
[Qt4.3] QTableView::setIndexWidget() (...and its position...)


Message 1 in thread

I'm using QTableView to display data from a custom
MyModel.  I needed lots of rendering control for the
last column, so MyDelegate calls
QTableView::setIndexWidget() with instances of
MyCustomWidget.

Everything works fine, until the user resizes the
columns:  MyCustomWidget continues to paint in its
previous location, and not in the location to where
its column was moved.  When I reset the model,
however, all the index widgets "snap" to their correct
location in the column.

I can catch the QHeaderView::sectionResized() to
physically move my index widgets during/after the
column resizing, but shouldn't the index widget's
placement/painting happen automatically?  And, don't
the index widgets logically exist in their "cells" ...
so to where should I move them?

I think I'm missing some important understanding of
*what* these index widgets are, for what purpose, and
how they are to be used.  (Yes, I read the docs and
understand that they are intended for "read-only"
content within the model.)

Is there some other example or supporting
documentation
that can help me understand QTableView's index
widgets?

Specifically, MyModel has "record-rows", and
MyCustomWidget in the last column (that I'm setting as
the index widget) is *actually* a set of 
"rating/date/initials" indicating "sign-off".  Each
record has a variable number of "sign-offs" that I
display in (three) fixed columns, wrapping new
sign-offs to logical "rows" within that widget.  Thus,
all MyCustomWidget instances have the same width, but
some of them have more "sign-offs" and thus the
widget is "taller".  (Of course, QTableView nicely
handles rows of differing heights.)

It seems to work, although my sizeHint/resizing
infrastructure seems kind of klunky/in-elegant to me.

I'm using the QTableView::setIndexWidget() instead
of simply rendering the cell in MyDelegate because
it's slightly interactive (i.e., I needed more than
just an image displayed).

Is my use an abomination of 
QTableView::setIndexWidget(), and do you have a
suggestion for a different design?  (Logically, I just
want a normal table in my QTableView, except
MyCustomWidget behaves like a nested table.)

Thoughts?

--charley



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

--
 [ signature omitted ]