Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, March 2007
Re: Model update in QTreeView ?


Message 1 in thread

Gunnar Sletta schrieb:
> The function you're looking for is QAbstractItemModel.createIndex();
>
> http://doc.trolltech.com/qtjambi-1.0/com/trolltech/qt/core/QAbstractItemModel.html#createIndex(int,%20int) 
>
I'm having a similar problem but not the same it seems. If I have a 
dynamic datamodel, e.g. nodes are asynchronous queried when 
child(Object, int) is called and when the result from this query returns 
i want to update this node, how should i do that? I mean, in this case i 
only have the data but no idea which index it is on, therefor 
createIndex(int, int) is rather useless (sure, i could simply update the 
whole tree, but that's ... hu ;)).



Best regards

Georg Schild


Message 2 in thread

Georg Schild wrote:
> Gunnar Sletta schrieb:
> 
>> The function you're looking for is QAbstractItemModel.createIndex();
>>
>> http://doc.trolltech.com/qtjambi-1.0/com/trolltech/qt/core/QAbstractItemModel.html#createIndex(int,%20int) 
>>
> 
> I'm having a similar problem but not the same it seems. If I have a 
> dynamic datamodel, e.g. nodes are asynchronous queried when 
> child(Object, int) is called and when the result from this query returns 
> i want to update this node, how should i do that? I mean, in this case i 
> only have the data but no idea which index it is on, therefor 
> createIndex(int, int) is rather useless (sure, i could simply update the 
> whole tree, but that's ... hu ;)).

So you're saying that after you update all of node x' children you want 
to update the value of node x? Here you would need the Object -> 
QModelIndex function which is currently not available, but which is on 
our todolist.

-
best regards,
Gunnar


Message 3 in thread

Gunnar Sletta schrieb:
>
> So you're saying that after you update all of node x' children you 
> want to update the value of node x? Here you would need the Object -> 
> QModelIndex function which is currently not available, but which is on 
> our todolist.
Almost, but yes, i was looking for this function ;). I want to tell the 
tree to update this node's children, maybe by removing its children 
before (which is not the problem imho). So in the first way, before the 
query to the nodes children is triggered i simply return 0 children (or 
anything else), then after the query returned (i just call it query 
here, it's not database related) i trigger an update of this node. So 
the model will re-ask for its children etc.


best regards

Georg Schild


Message 4 in thread

Georg Schild wrote:
> Gunnar Sletta schrieb:
> 
>>
>> So you're saying that after you update all of node x' children you 
>> want to update the value of node x? Here you would need the Object -> 
>> QModelIndex function which is currently not available, but which is on 
>> our todolist.
> 
> Almost, but yes, i was looking for this function ;). I want to tell the 
> tree to update this node's children, maybe by removing its children 
> before (which is not the problem imho). So in the first way, before the 
> query to the nodes children is triggered i simply return 0 children (or 
> anything else), then after the query returned (i just call it query 
> here, it's not database related) i trigger an update of this node. So 
> the model will re-ask for its children etc.

Ideally you could return 0 the first time and then call 
QTreeModel.childrenInserted() when the children are in place, again this 
function takes a QModelIndex so you can't really call it...

-
Gunnar