csdn20210407
2022-06-26 14:48
采纳率: 100%
浏览 19

qt tableWidget 设置居中的奇葩报错?

界面上放一个tableWidget,16行,4列:

Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);

ui->tableWidget1->resizeColumnsToContents();

// set item center
for(int i = 0;i < ui->tableWidget1->rowCount();i++)
    for(int j = 0;j < ui->tableWidget1->columnCount();j++){
        ui->tableWidget1->item(i,j)->setTextAlignment(Qt::AlignCenter);
        qDebug()<<"i="<<i<<" "<<"j="<<j;
    }

}

如果第一个for循环 i 小于 8,程序正常运行,大于8就报错:RtlWerpReportException failed with status code :-1073741823.?

相关推荐 更多相似问题