Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED with Work-around] QFont setFixedPitch works in Qt 4.8, not in 5.0
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neveralull
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      neveralull
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved