When I try to add item to a QTableWidge (by code) the app never runs. It shows the Program Crashed dialog and then quits. Here’s the code I used:
QTableWidgetItem *something = new QTableWidgetItem(QString("A"));
ui->itemTable->setItem(1,1,something);
You have to put your code after
ui->setupUi(this)because this function creates all widgets that you will use in your program. Your original code tries to insert the item into a non-existing widget (I mean it doesn’t have allocated memory yet) and that’s why your program is getting crushed.It should be: