Quote Originally Posted by naresh
And in paint at end something like this:

Qt Code:
  1. Qxygen->model()->setData(index, sizeHint(option,index), Qt::SizeHintRole);
To copy to clipboard, switch view to plain text mode 
What is this?????????????????????????????????????????????? ??
You can't manipulate the model from a delagate (or the view)! It ruins the whole concept of having a model and a view in the first place. Did you have a look at my example? You can manipulate item height by using size hint role without even touching the delegate. So the only thing you need to do with the delegate is to provide multi line text rendering (code for which btw. is presented in this thread too).

BTW. I wanted to ask that question much earlier -- what is that strange "Qxygen" member for? You can access the model through a model index, so what do you need it for?

I think you should... hmm... redesign your approach to the whole problem. You want contacts and descriptions of them and icons and all that divided into groups. For me you can do it in two ways:
1. description can be a child of a contact
2. description can be a property (role) of a contact

In the first case you have a parent-child relation, which can easily be handled by using a tree (which has additional benefits of being able to (1) show or hide the description when you need it, (2) add more "properties" for the contact if you need them (for example a photo, cell phone number or whatever you want) each of them separated from others (meaning you can "click" on each of the properties and act upon clicking on them) and (3) you don't have to subclass the delegate or the subclass can be very trivial.

In the second case, you can use roles to achieve more or less the same -- you define DescriptionRole (or use ToolTipRole for that), CellPhoneRole, PhotoRole and whatever other properties you want. Then you have to subclass the delegate. First thing I would do would be to look at implementation of QItemDelegate::sizeHint to see how it changes item sizes and maybe implement your own based on that. Then you need to implement tha painting routine, which should look more or less like so:
1. if I'm paining a group node (no valid parent), call QItemDelegate implementation
2. if I'm painting a contact node (has valid parent), call own custom routine

And in the custom routine:
1. Calculate size and position of each of the "properties"
2. Paint each property according to style options and active properties


Then you can manipulate everything just by changing the model -- you don't have to touch the view (that's the whole concept of MVC, right?). You can turn on and off every property you want by either adding or removing nodes (approach 1) or changing item roles (approach 2). First approach is superior to the second one, as it's simpler (you don't have to calculate to many things yourself) and more powerful (you can handle each property separately as each of them is represented by a different item).