Results 1 to 3 of 3

Thread: Why my for loop always gets SIGSEGV in a QTableWidget?

  1. #1
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Why my for loop always gets SIGSEGV in a QTableWidget?

    hey guys, im programming a little programm with QTableWidget.
    But everytime i work with two for loops to get empy Cells etc, my programm crashes with SIGSEGV, i know what it is but i do not know why im getting it.
    Example:
    I'm trying to search for empty cells:
    Qt Code:
    1. void MainWindow::checkEmpty()
    2. {
    3. for(int row=0;row<getMaxRow();row++) //getMaxRow returns the rowCount
    4. {
    5. for(int col=0;col<getMaxCol();col++)
    6. {
    7. if(table->item(row,col)->text().isEmpty())
    8. {
    9. item->setText("");
    10. table->setItem(row,col, item);
    11. }
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    im in my table memory, but everything i launch it my programm crashes..
    many times im using this loops and everytime it kills my programm.
    i need to search for empy cells, to fill it with "" or a "0", because other functions will crash if in a cell is really nothing.
    can someone help me? i have to fill new cells with something like a space or a "0".

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why my for loop always gets SIGSEGV in a QTableWidget?

    QTableWidget::item (in line 7) may return 0. I think that it should be :
    Qt Code:
    1. if(table->item(row,col) == 0)
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Lesiok for this useful post:

    schinkengott (15th June 2015)

  4. #3
    Join Date
    Jun 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Why my for loop always gets SIGSEGV in a QTableWidget?

    thanks, but im searching for empty cells, and not cells with a 0 inside it.
    i want to get these empty cells filled with a 0

    EDIT: oh i saw what you ment!
    it works, thank you!!
    Last edited by schinkengott; 15th June 2015 at 15:18.

Similar Threads

  1. Replies: 4
    Last Post: 6th August 2011, 01:40
  2. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 16:31
  3. Sigsegv
    By babygal in forum Newbie
    Replies: 3
    Last Post: 2nd November 2010, 05:29
  4. QTextEdit SIGSEGV
    By Flayer in forum Qt Programming
    Replies: 4
    Last Post: 14th January 2010, 22:52
  5. sigsegv ?
    By mero in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 18:01

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.