Results 1 to 3 of 3

Thread: QFontDatabase loading font from resource

  1. #1
    Join Date
    Jun 2009
    Posts
    12

    Default QFontDatabase loading font from resource

    Hi,
    I want to load a font from the resource using QFontDatabase but it don't work. Here the code that i use :

    Qt Code:
    1. QFontDatabase fontDB;
    2. fontDB.addApplicationFont(":/GraphicsView/fonts");
    3.  
    4. foreach(QString s, fontDB.families())
    5. {
    6. qDebug() << s;
    7. }
    To copy to clipboard, switch view to plain text mode 

    Am i doing something wrong or it's impossible to load font from the resource ?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QFontDatabase loading font from resource

    Quote Originally Posted by myrky View Post
    Qt Code:
    1. fontDB.addApplicationFont(":/GraphicsView/fonts");
    To copy to clipboard, switch view to plain text mode 
    Is this actually a font called "fonts" ?

  3. #3
    Join Date
    Jun 2009
    Posts
    12

    Default Re: QFontDatabase loading font from resource

    no it's the folder where i put all the font, i just found that i needed to specify the file name also.

    this solve my problem :

    Qt Code:
    1. fontDB.addApplicationFont(":/GraphicsView/fonts/font.ttf");
    To copy to clipboard, switch view to plain text mode 

    Thank you for your help

Similar Threads

  1. Loading images from resource files in webkit
    By redserpent7 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2015, 13:01
  2. QFontDatabase:Cannot find font directory
    By soumya in forum Qt for Embedded and Mobile
    Replies: 9
    Last Post: 10th November 2014, 06:08
  3. Replies: 4
    Last Post: 23rd November 2010, 17:15
  4. Error when loading QIcon from plugin resource on mac
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2010, 01:29
  5. Dynamic resource loading not work in another computer
    By GRUB in forum Installation and Deployment
    Replies: 2
    Last Post: 3rd September 2007, 10:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.