[SOLVED with Work-around] QFont setFixedPitch works in Qt 4.8, not in 5.0



  • 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);@



  • Changed my font from "Monospace" to "Courier" for a workaround. But I wonder why it doesn't work like it used to?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.