QTableWidget problem
-
Hi, I have a problem and I don't know why.
So, I have a QTable widget, (10 rows, 8 columns) in my case. With a loop I create in three column a QTableWidgetItem.
I use table->setItem(currentRow,2,new QTableWidgetItem); and the same for column 3 and 4.
I am sure that these lines are called and currentRow index take all values from 0 to 9.The problem is, when I use cell, my software crash.
I use table->item(i,2)->setBackgroundColor(Qt::darkGray); 0<=i<=9 it's sure, I print "i" index;
The setBackgroundColor works but I use the line directly after setText(text) or text() and now the software crash.
The QTableWiodgetItem exists, and it's works for one method and not for setText and text.Someone have an idea ?
Sorry for my english. If you need more information, tell me.
Thanks a lot.
-
when I initialize my table:
@
for(int currentRow=0; currentRow<nbRow; ++currentRow) {
...
if(nbSystem>1) {
table->setSpan(currentRow,2,nbSystem,1);
table->setSpan(currentRow,3,nbSystem,1);
table->setSpan(currentRow,4,nbSystem,1);
}table->setItem(currentRow,2,new QTableWidgetItem);
table->setItem(currentRow,3,new QTableWidgetItem);
table->setItem(currentRow,4,new QTableWidgetItem);
...
}
@And when I use it:
@
for(int currentRow=0; currentRow<nbRow; ++currentRow) {
QString posX = posList.at(6);
QString posY = posList.at(7);
QString posZ = posList.at(8);table->item(i,2)->setBackgroundColor(Qt::darkGray); table->item(i,2)->setText(posX); table->item(i,3)->setBackgroundColor(Qt::darkGray); table->item(i,3)->setText(posY); table->item(i,4)->setBackgroundColor(Qt::darkGray); table->item(i,4)->setText(posZ);
}
@When the setText() is called, my software crash
Sorry I can't copying my real code because it is on an another computer and I can't put USB key.
I think perhaps the problem is the setSpan but it's not sure
[edit: code highlighted / Denis Kormalev]
-
Please don't forget to highlight code with @ tags. I've done it in your last comment for you, but in future please do it yourself