[Qt-interest] Model/View programming: QTableView with custom item delegate or custom view class?

Robert Hairgrove evorgriahr at hispeed.ch
Mon Jan 18 22:16:08 CET 2010


I need to create a custom view for editing teachers' schedules which 
have lessons of varying length and am not quite sure of the best way of 
going about it. I already implemented one version using a QTableView, 
but this works only under the assumption that all lessons have lengths 
that are some integer multiple of the smallest time slot. Lessons are 
represented by colored rectangles on a white background. I would like to 
offer the user more flexibility -- lessons should be able to cross item 
borders if necessary, and lessons can be of any duration as specified by 
the user.

Of course, it is lots of work to inherit directly from QAbstractItemView 
and have to deal with all the scrolling, etc. I took a look at the Pie 
Chart example, and it didn't look too intimidating, although it is still 
a lot of work to implement the paintEvent() function, for example. Can I 
do it with a QTableView and a custom item delegate instead?



More information about the Qt-interest-old mailing list