【发布时间】:2013-05-07 17:23:46
【问题描述】:
我有一个名为 tw_topic 的 QTableWidget。它不是空的。在另一个函数中,我需要项目的文本。
代码:
for(int i = ui->tw_topic->rowCount(); i >= 0; i--)
{
//should return the first item of the first column
const QString itm = ui->tw_topic->item(i, 0)->text();
//Here I will do some other stuff...
}
不知何故,它在它被初始化的时候崩溃了,我不知道为什么。
【问题讨论】:
-
ui, tw_topic之一或item(i, 0)返回的内容出于某种原因是NULL。尝试将语句分解为单个步骤。你会发现哪一个是NULL。或者调试并尝试单步执行该函数。
标签: c++ qt qtablewidget qstring qtablewidgetitem