Project

General

Profile

WTableView or WStandardItemModel reload

Added by Olaf van der Meer almost 5 years ago

Hi,

What is the best way to reload data in WTableView?

I have got a WTableView with a WStandardItemModel as model.

In the model, I create the columns and load the data. The WTableView can be sorted and the columns width can be resized by the user in the browser.

I first have tried to use WStandardItemModel.clear() to clear the data. This works but it clears the column sorting and column sizing also.

Now I use removeRows() like this:

if ( WStandardItemModel.getRowCount() > 0 ) // if 0 rows it throws an exception

WStandardItemModel.removeRows( 0, WStandardItemModel.getRowCount() );

This clears the data correct, but after adding the new data it is not sorted any more.

How should I reload the data?

Thanks.


Replies (2)

RE: WTableView or WStandardItemModel reload - Added by Henry Morgan over 4 years ago

Hello

Nobody knows what's wrong and what's right (to compare with c wt which is great)

I reload like this - reset model at first and re-insert model. Everything is ok

@

woDataModel.reset();

woTable.setModel(woDataModel);

@

RE: WTableView or WStandardItemModel reload - Added by Henry Morgan over 4 years ago

btw it's good to collect all selected WModelIndex's before reset and return it back right after resetting.

    (1-2/2)