Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]Global Fontloader
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Global Fontloader

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 1.7k Views 3 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.
  • MonomixM Offline
    MonomixM Offline
    Monomix
    wrote on last edited by Monomix
    #1

    I'm hoping there's a quick and obvious answer to this one that I'm somehow missing:

    I have a font, loaded from file using a Fontloader object, that I use in several different QML files. At the moment, there's a Fontloader object in each file - is there any way to declare a single, global Fontloader, and assign the loaded font to objects across multiple files?

    p3c0P 1 Reply Last reply
    0
    • MonomixM Monomix

      I'm hoping there's a quick and obvious answer to this one that I'm somehow missing:

      I have a font, loaded from file using a Fontloader object, that I use in several different QML files. At the moment, there's a Fontloader object in each file - is there any way to declare a single, global Fontloader, and assign the loaded font to objects across multiple files?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Monomix You can do it using setFont for QGuiApplication.

      QGuiApplication app(argc, argv);
      app.setFont(QFont("xkcd"));
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      return app.exec();
      

      157

      1 Reply Last reply
      1
      • X Offline
        X Offline
        xargs1
        wrote on last edited by
        #3

        Put it in a Singleton?

        1 Reply Last reply
        2
        • MonomixM Offline
          MonomixM Offline
          Monomix
          wrote on last edited by Monomix
          #4

          Thanks for the suggestions! I ended up going with a singleton, in the same way as described here:

          http://stackoverflow.com/questions/27692914/where-to-put-qt-qml-non-visual-application-components

          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