I am using QFont’s setFixedPitch in various places in my code in Qt 4.8, and it works perfectly. All the characters including letters, numbers, and blanks line up in perfect columns. But in Qt5.0, the displays are all wrong due to variable fonts, i.e. setFixedPitch no longer works. Each character is a different width.
Typical code:
setting the font
QFont* memoryDumpFont = new QFont("Monospace", 9);
memoryDumpFont->setFixedPitch(true);
memoryDumpFont->setStretch(110);
writing a table item
QTableWidgetItem *item = new QTableWidgetItem(value);
item->setTextAlignment(Qt::AlignCenter);
item->setFont(*memoryDumpFont);
ui->MemoryDump->setItem(row, col, item);
↧