View Full Version : Custom tablemodel and delegates problem.

2nd November 2011, 11:01
I have reviewed all the help related with delegates for table-model.
I see table.setitemdelegate() (and the itemdelegateforcolumn and itemdelegate for row).
If I use this approach, I need to set the data of items before the table was showed. ( as startdelegates does)
But this is a problem for me.
I have a custom tablemodel to retrieve data. I can detect the data request, but I dont know how to set the data for the delegate because the paint event of the delegates if triggered before any data request event...
How can I fix this problem ? I'd need a data - role request that lets me set the right data .
And I have a model that retrieves data from a internal store system designe to deal with ten of thousands rows of data.

All the examples I see has not custom tablemodel.... (the items are added to the tableview.... )
I need help on this..

4th November 2011, 16:15
In the model you signal that the data has changed with

Q_EMIT dataChanged();

in the setData() method and any other place the data can change.

If you are doing things like sorting the data you will also need to emit/call




When you insert rows in your table you need to call beginInsertRows() ... endInsertRows() and a similar thing for removing rows. These are what signal the view that the model has changed and things in the view need up dating and that is when the delegate is used by the view.

At least the above is what works for my custom view/model code.

9th November 2011, 08:24
Aha ! Thank you very much