以下代码正常运行。但是当我尝试调试它时,我在标有“*”的字符串中出现了分段错误错误。我做错了什么?
要连接信号和插槽我使用下一个consctuction:
QObject::connect(ui->treeWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(tree_widget_item_selected(QModelIndex)));
void MainWindow::tree_widget_item_selected(QModelIndex selected)
{
ui->tableWidget->clearContents();
int i = 0;
int indexes[5];
while (selected.isValid()) {
indexes[i] = selected.row();
i++;
selected = selected.parent(); // *
}
// some other code
}