PDA

View Full Version : Slow refresh QsqlQueryModel with QTableView



Mhaylson
19th August 2015, 18:05
First of all, i am brazilian therefore my english is not verry good.

I have a QTableView using QSqlQueryModel in a search screen and my table contains more than 30,000 records. I created a function to update my table. But every time I open the search screen I need to upgrade I wonder how to solve the problem! Help me please!

The code to update my table:

QString strTemp;

m_ModelProduct->clear();

m_ModelProduct->setQuery(SQL_LOCAL_PRODUCTS);

while( m_ModelProduct->canFetchMore())
{
m_ModelProduct->fetchMore();

strTemp.sprintf(" Produtos ( Processando... ) ");

m_ui->groupBoxMedicamentos->setTitle(strTemp);
}


m_ui->tableViewSearch->setModel( m_ModelProduct);

SetHeaderTables();

anda_skoa
19th August 2015, 18:27
Why the loop?

The update method would not need to do anything other than to set the query on the model, no?

Also you have not indicated what the problem is that you are trying to solve.

Cheers,
_