title: Qt- Add custom font from resource
body: <p>I added this font to resource: <em>BYekan.ttf</em><br>
  I want to use this font in my application. I've tried this :</p>
  
  <pre><code>    QFont font(":/images/font/BYekan.ttf");
      nLabel-&gt;setFont(font);
      nLabel-&gt;setText(tr("This is for test"));
      layout-&gt;addWidget(nLabel);
  </code></pre>
  
  <p>But, I guess it's not working. How to use it?</p>
  
  <p>Edit:
  After reading <a href="http://www.qtforum.org/article/25367/embedding-custom-fonts.html" rel="noreferrer">this question</a> , I've tried again :</p>
  
  <pre><code>int fontID(-1);
  bool fontWarningShown(false);
  QFile res(":/images/font/Yekan.ttf");
  if (res.open(QIODevice::ReadOnly) == false) {
      if (fontWarningShown == false) {
          QMessageBox::warning(0, "Application", (QString)"Impossible d'ouvrir la police " + QChar(0x00AB) + " DejaVu Serif " + QChar(0x00BB) + ".");
          fontWarningShown = true;
      }
  }else {
      fontID = QFontDatabase::addApplicationFontFromData(res.readAll());
      if (fontID == -1 &amp;&amp; fontWarningShown == false) {
          QMessageBox::warning(0, "Application", (QString)"Impossible d'ouvrir la police " + QChar(0x00AB) + " DejaVu Serif " + QChar(0x00BB) + ".");
          fontWarningShown = true;
  
      }
      else
          nLabel-&gt;setFont(QFont(":/images/font/Yekan.ttf", 10));
  }
  </code></pre>
  
  <p>I compare this font and other font, but there isn't any different on Qt. why?</p>