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:
Code:
void MainWindow::checkEmpty()
{
for(int row=0;row<getMaxRow();row++) //getMaxRow returns the rowCount
{
for(int col=0;col<getMaxCol();col++)
{
if(table->item(row,col)->text().isEmpty())
{
item->setText("");
table->setItem(row,col, item);
}
}
}
}
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".
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 :
Code:
if(table->item(row,col) == 0)
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!!