I want to have a read only text in QTableWidget
, so I decided to insert a QLabel
in each cell. Unfortunately I'm getting the following look:
Here is the code that I use for this:
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);
}
I see two issues:
When I run the code I got a bunch of the following warnings: QPaintDevice::metrics: Device has no metric information
mytext
is displayed in the corner header cell. Why is this happening? What am I doing wrong and how to fix this?