Results 1 to 6 of 6

Thread: QTableWidget crashes on setItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Sant'Elpidio a Mare, Italy
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4

    Default QTableWidget crashes on setItem

    I everyone,

    I'm trying to fill a QTableWidget with some items, but when trying setItem it segmentation faults.

    Qt Code:
    1. // vLastId is a ID int
    2. // n becomes 2
    3. // query is valid
    4. int n=viewport->db->Count("customer_addresses a,contacts c",
    5. "c.id_customer=a.id_customer AND"+QString::number(vLastId));
    6. QSqlQuery query=viewport->db->Select(",a.ragsoc","customer_addresses a,contacts c",
    7. "c.id_customer=a.id_customer AND"+QString::number(vLastId));
    9. // two columns defined elsewhere
    10. ui.tbwcaddresses->setSortingEnabled(false);
    11. ui.tbwcaddresses->setRowCount(n);
    12. int row=0;
    13. while(
    14. {
    15. CTableWidgetItem *zid=new CTableWidgetItem(query.value(0).toString());
    16. ui.tbwcaddresses->setItem(row,0,zid); // this row fails and throws exception
    18. CTableWidgetItem *iragsoc=new CTableWidgetItem(query.value(1).toString());
    19. ui.tbwcaddresses->setItem(row,1,iragsoc); // this doesn't fail, and seems the same operation!
    20. ...
    21. row++;
    22. }
    23. ui.tbwcaddresses->setSortingEnabled(true);
    To copy to clipboard, switch view to plain text mode 
    If I bypass the excepting row, the second setitem works well.
    I've done this operation tons of times before, but never this problem... What could it be?

    Thank you in advance
    Last edited by Raccoon29; 18th September 2008 at 09:17.

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

Similar Threads

  1. Replies: 5
    Last Post: 27th May 2006, 13:44

Tags for this Thread


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.