我正在使用 QtableWidget 填充从 ROS 消息中收集的数据:
ui->stat->setColumnCount(3);
//ui->stat->setRowCount(5);
count_row=0;// keep track of table rows
ui->stat->setColumnWidth(0,145);
ui->stat->setColumnWidth(1,50);
ui->stat->setColumnWidth(2,300);
QStringlist labels;
labels.push_back(" Time");
labels.push_back("Type");
labels.push_back("Message ");
ui->stat->setHorizontalHeaderLabels(labels);
QTableWidgetItem* text = new QTableWidgetItem();
QTableWidgetItem* msgType = new QTableWidgetItem();
QTableWidgetItem* time = new QTableWidgetItem();
count_row=count_row%5;
ui->stat->setItem(count_row,0,time);
ui->stat->setItem(count_row,1,msgType);
ui->stat->setItem(count_row,2,text);
count_row++;
for(int i=4;i>=0;i--)
ui->stat->showRow(i);
在运行程序时,我收到分段错误错误