PDA

View Full Version : QTableWidget Sql Query 25.000 records



aekilic
12th August 2008, 11:17
Dear All

I have a big problem like this...

I have the following code for QTableWidget


treeStoklarStokBilgisi->clear();
treeStoklarStokBilgisi->setUpdatesEnabled( false );
QSqlDatabase cachedb = QSqlDatabase::database("cachedb");



QSqlQuery anas("", cachedb);

QString query;
QString arananStokNo = lineStoklarParcaNo->text();
QString arananAciklama = lineStoklarAciklama->text();
QString arananMakina = comboStoklarMakina->currentText();

query = "SELECT stok.stokid, stokisim, parcano FROM stok LEFT JOIN stokindex ON stokindex.stokid = stok.stokid WHERE stok.stokid IN (SELECT stokid FROM stokindex WHERE parcano like '" + arananStokNo + "%')";
if (radioMakina->isChecked())
{
query += " AND stokid IN (SELECT makinaindex.stokid FROM makinaindex, makina WHERE makinaindex.makinaid=makina.makinaid AND makina.makina_isim ~*'" + arananMakina + "')";
}

anas.exec(query);

while(anas.next())
{
QTreeWidgetItem *i = new QTreeWidgetItem(treeStoklarStokBilgisi);
QString aciklama;
QString stokno;

//aciklama = anas.value(1).toString();
//stokno = anas.value(0).toString();
// i->setStatusTip(0, stokno);
i->setText(0, anas.value(2).toString());
i->setText(1, anas.value(1).toString());
i->setText(2, anas.value(0).toString());

QSqlQuery parnox;
QSqlQuery parnox("", cachedb);
parnox.exec("SELECT parcano FROM stokindex WHERE stokid=" + stokno + " ORDER BY sorulma DESC");
int iR=1;
while(parnox.next())
{
if(iR==1)
{
i->setStatusTip(0, parnox.value(0).toString());
i->setText(0, parnox.value(0).toString());
i->setText(1, aciklama);
i->setText(2, stokno);

iR++;
}
else if(iR>1)
{
QTreeWidgetItem *alti = new QTreeWidgetItem(i);
alti->setStatusTip(0, parnox.value(0).toString());
alti->setText(0, parnox.value(0).toString());
alti->setStatusTip(1, stokno);
alti->setText(2, stokno);
}
}
}
treeStoklarStokBilgisi->setUpdatesEnabled( true );

But the problem is when I try to load the data It takes to much time for loading the tree...

Can anybody help me to solve this problem...

patrik08
12th August 2008, 14:18
Can you post constructor from cachedb?

aekilic
12th August 2008, 14:54
cachedb is a database that I copy from postgres to memory to sqlite...

If you need the codes I could sent