PDA

View Full Version : How to lock data petition for a custom model ?



tonnot
31st October 2011, 08:48
I have noted that when I'm edit a cell (custom model & table view) the table model ask for vales of the other visible cells. If I return a Qvariant invalid (as dochelp advise )
Note: If you do not have a value to return, return an invalid QVariant instead of returning 0.
what I get are empty the cells....

Is there any way to lock the data petition ?
Thanks

ChrisW67
31st October 2011, 09:22
I have noted that when I'm edit a cell (custom model & table view) the table model ask for vales of the other visible cells. If I return a Qvariant invalid (as dochelp advise )
Note: If you do not have a value to return, return an invalid QVariant instead of returning 0.
what I get are empty the cells....
Yes, of course you do. You told the view there was no data to display for the given index by returning QVariant(). If the index in the model has data for the given role then return the data.

Is there any way to lock the data petition ?
I have no idea what this means.

melonvenhusen
31st October 2011, 09:57
In table view cell are merge in to each other and overlap.

tonnot
31st October 2011, 12:47
What I want is some way to tell the table or model that does not refresh the content of any cell.
Now, I'm viewing how when I edit a cell first I receive a 'Data' event for the whole cells.
In case I have a 100x100 Table, I'd have an unusefull time used for refresh an information that is not neccesary.
( In this case If I return a QVariant what I get is to clear the cells...)
So, in case of edit a cell, how can I lock or disable the Data refreshing ?
Thanks.

ChrisW67
31st October 2011, 20:40
The view will request the indexes it requires in order to maintain a consistent view of the model. It does this based on changes made to the view made by users (e.g. resize an make more visible) and the signals emitted by your model as it modifies data. What signals are you emitting from your custom model?

tonnot
2nd November 2011, 08:32
By now, I only emit datachanged.
I have tested the addressbook example and it happens the same.
When you do a double click to edit a cell, you see (with a qdebug) a data petition for every visible cell.
(And there is no resize event).

I'd understand logical this data refresh when I end my edition (in example after enter), but not before edit a cell.
Repeat, I have a problem because I spend a significant time doing a data refreshing that is not neccesary.
Can be a trick to mark some 'I'm editing a cell ' var and if it is true return index.data(display-role) ? (insted the data I have to search into my store-system) ??
Thanks.