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. Show only application fonts in QFontComboBox?
Forum Updated to NodeBB v4.3 + New Features

Show only application fonts in QFontComboBox?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    At the start of my application, I call
    @QFontDatabase::removeAllApplicationFonts();@
    and then add some fonts that I want to use.

    Is there any way to restrict QFontComboBox to only those fonts?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      since it's a ordinary QComboBox you can set your own model to it.
      QFontComboBox uses a simple QStringListModel, containign the font names as strings.
      Take a look at the Qt source of QFontComboBoxPrivate::_q_updateModel() for further info.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        Thanks!

        (message too short)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          Didn't work. The model is automatically reset to the whole font database in too many places. Since setModel is not virtual, there's also no clean way to override this behavior.

          Seems the only way to do this is to write your own widget.

          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