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. Multiple Font Sizes with on the fly sizing
Forum Updated to NodeBB v4.3 + New Features

Multiple Font Sizes with on the fly sizing

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.3k 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.
  • H Offline
    H Offline
    HowardWi
    wrote on last edited by
    #1

    Hi,

    I'm looking for ideas.

    Our application uses three different font sizes (small, medium, large). I want to be able to change any of them on the fly and have the application update correctly. That is, if I change the medium font from size 10 to 12, I want all current widgets of size 10 to change to size 12 and of course, new widgets would come in at size 12.

    Currently, I have my own setFont and track the widgets there. Then when the font size is changed I can just set the font on the widget list to the new size and the display updates. This is slow and I'm having some troubles with QTreeWidgetItems (and sip).

    First a little background. This application runs standalone, but mostly we run it within Maya (which is now a QT app too). So I can't use QApplication.setFont because that would change Maya's fonts too. So it seems I do need a font manager of some kind.

    My biggest problem is the calls to QLabel and others that don't explicitly setFont. I have to find all those calls and do a setFont there.

    Does anyone have any easier suggestions as how to do global font changes and have them be live right away?

    Thanks,
    Howard

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      Qtnovice
      wrote on last edited by
      #2

      In MainWindow you could use the following line:
      @ this->setStyleSheet(QString::fromUtf8("font: 10pt FreeMono;"));@

      to set FreeMono 12pt font globally...

      You can also limit the stylesheet to some widgets by properly defining the stylesheet, e.g:
      @ this->setStyleSheet(QString::fromUtf8("QLabel {font: 10pt;}"));@
      just to set font size only for QLabels...

      I hope it helps.

      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