Results 1 to 3 of 3

Thread: QTableWidget Sql Query 25.000 records

  1. #1
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QTableWidget Sql Query 25.000 records

    Dear All

    I have a big problem like this...

    I have the following code for QTableWidget

    Qt Code:
    1. treeStoklarStokBilgisi->clear();
    2. treeStoklarStokBilgisi->setUpdatesEnabled( false );
    3. QSqlDatabase cachedb = QSqlDatabase::database("cachedb");
    4.  
    5.  
    6.  
    7. QSqlQuery anas("", cachedb);
    8.  
    9. QString query;
    10. QString arananStokNo = lineStoklarParcaNo->text();
    11. QString arananAciklama = lineStoklarAciklama->text();
    12. QString arananMakina = comboStoklarMakina->currentText();
    13.  
    14. 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 + "%')";
    15. if (radioMakina->isChecked())
    16. {
    17. query += " AND stokid IN (SELECT makinaindex.stokid FROM makinaindex, makina WHERE makinaindex.makinaid=makina.makinaid AND makina.makina_isim ~*'" + arananMakina + "')";
    18. }
    19.  
    20. anas.exec(query);
    21.  
    22. while(anas.next())
    23. {
    24. QTreeWidgetItem *i = new QTreeWidgetItem(treeStoklarStokBilgisi);
    25. QString aciklama;
    26. QString stokno;
    27.  
    28. //aciklama = anas.value(1).toString();
    29. //stokno = anas.value(0).toString();
    30. // i->setStatusTip(0, stokno);
    31. i->setText(0, anas.value(2).toString());
    32. i->setText(1, anas.value(1).toString());
    33. i->setText(2, anas.value(0).toString());
    34.  
    35. QSqlQuery parnox;
    36. QSqlQuery parnox("", cachedb);
    37. parnox.exec("SELECT parcano FROM stokindex WHERE stokid=" + stokno + " ORDER BY sorulma DESC");
    38. int iR=1;
    39. while(parnox.next())
    40. {
    41. if(iR==1)
    42. {
    43. i->setStatusTip(0, parnox.value(0).toString());
    44. i->setText(0, parnox.value(0).toString());
    45. i->setText(1, aciklama);
    46. i->setText(2, stokno);
    47.  
    48. iR++;
    49. }
    50. else if(iR>1)
    51. {
    52. alti->setStatusTip(0, parnox.value(0).toString());
    53. alti->setText(0, parnox.value(0).toString());
    54. alti->setStatusTip(1, stokno);
    55. alti->setText(2, stokno);
    56. }
    57. }
    58. }
    59. treeStoklarStokBilgisi->setUpdatesEnabled( true );
    To copy to clipboard, switch view to plain text mode 

    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...

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget Sql Query 25.000 records

    Can you post constructor from cachedb?

  3. #3
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget Sql Query 25.000 records

    cachedb is a database that I copy from postgres to memory to sqlite...

    If you need the codes I could sent

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.