我有QPushButton這個信號:QTWidgets QTableWidget的崩潰與段錯誤
void MainWindow::on_addNode_clicked()
{
ui->nodesTable->insertRow(ui->nodesTable->rowCount());
if(ui->nodesTable->rowCount()>1)
{
ui->nodesTable->item(ui->nodesTable->rowCount()-1, 0)->setText(ui->nodesTable->item(ui->nodesTable->rowCount()-2,0)->text());
}
else
{
ui->nodesTable->item(ui->nodesTable->rowCount()-1, 0)->setText(QString::fromStdString("0"));
}
}
但它與分段故障,每次當我點擊按鈕崩潰。據我瞭解,項目(...)給nullptr,但爲什麼?
但是我在QTCreator的UI disigner中創建了列。如果它在那裏,我需要從另一行設置值。 – dimas