在使用QT tableWidget 和tableview中单独设置某个单元格颜色,使用下列语句: ui->tableWidget->item(2,1)->setBackground(Qt::red); 结果编译没有问题,但运行就异常退出程序, 报错: Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process 。
网上找了很多相关资料也没有解决,在偶然一次发现,只要单元格已经被赋值了,就正常,没有赋值就异常退出,因此得出,要对单元格进行设置颜色,要先进行赋值语句。