c++ Qt QTableWidgetItem导致崩溃
C++ Qt QTableWidgetItem causes crash
我有一个名为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...
}
在itm初始化的时候崩溃了,我不知道为什么。
我发现是for循环出了问题。
应该是这样的:
for(int i = 0; i < ui->tw_topic->rowCount(); i++)
{
// stuff
}
如果i
是ui->tw_topic
的最后一行,它将崩溃。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 内联映射初始化的动态atexit析构函数崩溃
- 执行函数时导致崩溃的变量
- 程序崩溃并显示"std::out_of_range"错误
- CoInitialize()在单独的线程上崩溃而不返回
- 使用调试/崩溃报告将应用程序部署到客户端
- 为什么所有C++编译器都会崩溃或挂起此代码
- 为什么lambda在clang上崩溃而不是在gcc上崩溃
- 为什么我的多线程作业队列崩溃
- ExtractIconEx:可以工作,但偶尔会崩溃
- 当用户在qtablewidget中输入单元格时,如何获得信号?C++
- 为什么引用传递会导致此崩溃(C++)
- 试图创建流或fopen时程序崩溃
- 类对象数组的问题会导致崩溃
- 排序时无法执行交换操作.我做的时候它会崩溃.为什么
- 为什么要增加导致崩溃的指针
- 在虚幻引擎中删除NXOpen对象时崩溃
- 为什么它只打印双链接列表的第一个值,而我的程序却崩溃了
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- QTWidgets QTableWidget因segfault而崩溃