[quote author="Andre" date="1319130593"]
admins note
Please edit your post if you want to change it, instead of just re-posting the entire thing. I have fixed your image. [/quote]
Thank you for the reply. I did try to edit the post. I used Mozilla ff (various versions), and for some reason on posting after the edit it did not work. I could preview and see the image after edit, but could not post. I've not been able to post from Firefox (version 3.6 and thereafter version 5) from windows XP??? I had to change rendering to explorer to post in the first place. Therefore my apology for reposting the whole thing. This I now posted from ff under linux at home and it seems to work better.
I agree that allowing roles to render seems wrong if you can't do it consistently for all kinds of rendering. We initially used a delegate for the same thing, but sometimes data exists (can exist) in the model that influences rendering, but does not form part of the actual viewable data e.g:
I have 10 parameters, 8 of which is displayed, two which influence the color and font. The column count is then specified as 8, and the delegate typically is not intimate enough with a model (and should not be) to know that non displayed data influences displayed data.
Furthermore, what lead me to using the roles for the colour, was initially the fact that my parameters influences the width of table column headers (as well as width of editors...), for this reason it is reasonable to suggest a font size from the model, as the view has no clue. Inorder to give the correct size hint I had to be aware of the font too (and at that stage only the delegate was aware of this). The model cannot request the font used from the delegate (else everything becomes too coupled).
My solution would be - keep all data (even rendering data) in the model (I suppose the model can lend from styles). If one wants rendering be different from what was specified/hinted by the model, I would then suggest a proxy model. The delegate then exists solely for the purpose of defining editor type.
Scenario:
We want columns in table views to autoscale iaw the parameters in conjunction with header text: max( paramWidth, headerWidth).
How? By determining the maximum width of a field.
Then we require the font.
Therefore the model needs to be font aware.
Qt::FontRole to the rescue.
But font role influences rendering, and with customized delegates the model cannot know the font.
Therefore, as with StyledItemDelegate, the model dictates rendering (it has to, otherwise the design will have to change?).
Finally, delegates use item indexes, and undisplayed data (in the model) might influence rendering of displayed data. QStyledItemIndex uses model indexes as supplied by QTableView, which is determined by the visible row/col count. A general delegate can therefore not render correctly without being intimate with the model - too coupled.
Again - we need roles in the model...
I don't know if I'm making sense to you.
Kind regards, thanks again for your reply and patience.
Werner