<分区>
我想在QTableWidget
中有一个只读文本,所以我决定在每个单元格中插入一个QLabel
。不幸的是,我看到了以下内容:
这是我为此使用的代码:
for (int row = 1; row < ui->currentSetting1TableWidget->rowCount(); row++)
for (int col = 1; col < ui->currentSetting1TableWidget->colorCount(); col++) {
QLabel *label = new QLabel(ui->currentSetting1TableWidget);
label->setText("mytext");
ui->currentSetting1TableWidget->setCellWidget(row, col, label);
}
我看到两个问题:
当我运行代码时,我收到了以下警告: QPaintDevice::metrics: 设备没有度量信息
mytext
显示在角标题单元格中。为什么会这样?我做错了什么以及如何解决这个问题?