调试程序时QModelIndex :: parent导致分段错误

时间:2013-11-16 13:51:47

标签: qt debugging windows-7 segmentation-fault qmodelindex

以下代码正常运行。但是当我尝试调试它时,我在标有“*”的字符串中出现了分段错误错误。我做错了什么?

要连接信号和插槽我使用下一个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
}

0 个答案:

没有答案