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
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    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 c.id="+QString::number(vLastId));
    6. QSqlQuery query=viewport->db->Select("a.id,a.ragsoc","customer_addresses a,contacts c",
    7. "c.id_customer=a.id_customer AND c.id="+QString::number(vLastId));
    8.  
    9. // two columns defined elsewhere
    10. ui.tbwcaddresses->setSortingEnabled(false);
    11. ui.tbwcaddresses->setRowCount(n);
    12. int row=0;
    13. while(query.next())
    14. {
    15. CTableWidgetItem *zid=new CTableWidgetItem(query.value(0).toString());
    16. ui.tbwcaddresses->setItem(row,0,zid); // this row fails and throws exception
    17.  
    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.
    --
    raccoon29

    "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

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.