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

Qt-interest Archive, March 2007
updating a tableview


Message 1 in thread

Hi, i am using a tableview to display data coming from a qsqlquerymodel
then i update the dat of the db via a qsqlquery, how can i force the update
of the tableview?

thanks

Message 2 in thread

Francesco Lamonica wrote:
>Hi, i am using a tableview to display data coming from a qsqlquerymodel
>then i update the dat of the db via a qsqlquery, how can i force the
update
>of the tableview?

you shouldn't need to touch the tableview, instead try to reset the
query of the qsqlquerymodel.

Cheers,
Peter

--
 [ signature omitted ] 

Message 3 in thread

On 3/30/07, Peter Prade <prade@xxxxxxxxxxx> wrote:
>
> Francesco Lamonica wrote:
> >Hi, i am using a tableview to display data coming from a qsqlquerymodel
> >then i update the dat of the db via a qsqlquery, how can i force the
> update
> >of the tableview?
>
> you shouldn't need to touch the tableview, instead try to reset the
> query of the qsqlquerymodel.


i did try to set the query to the query it was already there but the
tableview does not change. (and the data was commited)

Message 4 in thread

>i did try to set the query to the query it was already there but the 
>tableview does not change. (and the data was commited)

Thats odd. I'd try to call clear() before i set the query again. or even
just to see where the problem is, switch to another query for testing.

Cheers,
Peter 


--
 [ signature omitted ] 

Message 5 in thread

On 3/30/07, Peter Prade <prade@xxxxxxxxxxx> wrote:
>
> >i did try to set the query to the query it was already there but the
> >tableview does not change. (and the data was commited)
>
> Thats odd. I'd try to call clear() before i set the query again. or even
> just to see where the problem is, switch to another query for testing.
>
> Cheers,
> Peter


saved the query
clear()'d the model
setQuery()

same result, tableview isnt updated :(
i will try to switch to another query to see if anything happens

thanks

Message 6 in thread

On 3/30/07, Francesco Lamonica <alienpenguin@xxxxxxxxx> wrote:
>
>
>
> On 3/30/07, Peter Prade <prade@xxxxxxxxxxx> wrote:
> >
> > >i did try to set the query to the query it was already there but the
> > >tableview does not change. (and the data was commited)
> >
> > Thats odd. I'd try to call clear() before i set the query again. or even
> > just to see where the problem is, switch to another query for testing.
> >
> > Cheers,
> > Peter
>
>
> saved the query
> clear()'d the model
> setQuery()
>
> same result, tableview isnt updated :(
> i will try to switch to another query to see if anything happens
>
> i now can confirm that changing the query to a different one does trigger
the tableview update... is there a cache mechanism?

thanks

Message 7 in thread

Francesco Lamonica wrote:
>saved the query
>clear()'d the model
>setQuery()
>same result, tableview isnt updated :( 
>i will try to switch to another query to see if anything happens

>i now can confirm that changing the query to a different one does
trigger >the tableview update... is there a cache mechanism?

i'd report it as a bug to qt-bugs@xxxxxxxxxxxxx

Cheers,
Peter

--
 [ signature omitted ] 

Message 8 in thread

On 3/30/07, Liang Qi <cavendish.qi@xxxxxxxxx> wrote:
>
> Hi,
>
> I think you need reset() or dataChanged()
> http://doc.trolltech.com/4.2/qabstractitemmodel.html#dataChanged


hi, reset is protected and i cant call it directly,  as for datachanged... i
havent tried it yet, but i do have to figure out the indexes of the model...
is there a way to pass the maximum values? i dont know how many
modifications are done so i dont know the number of rows in the table

tahnks for your help

Message 9 in thread

I think you can create your own slotAllDataChanged() in your model, in
there, you can know the rowCount() and columnCount(), then it's easy.

On 30/03/07, Francesco Lamonica <alienpenguin@xxxxxxxxx> wrote:
>  hi, reset is protected and i cant call it directly,  as for datachanged...
> i havent tried it yet, but i do have to figure out the indexes of the
> model... is there a way to pass the maximum values? i dont know how many
> modifications are done so i dont know the number of rows in the table

Regards,
Liang Qi

-- 
 [ signature omitted ] 

Message 10 in thread

On 3/30/07, Liang Qi <cavendish.qi@xxxxxxxxx> wrote:
>
> I think you can create your own slotAllDataChanged() in your model, in
> there, you can know the rowCount() and columnCount(), then it's easy.


i'll try, however i find it strange that there is not an easier method to
refresh data of a model