How to set a font from a ini file?
-
wrote on 20 Jun 2015, 02:55 last edited by
So? How to set a front from a ini file? Because i have some problems with the qt fonts(because the error: font database cannot find font directory - is qt installed correctly) . So i want use fonts default of system.
Here what i did:
[General]
Fonts=QCoreApplication::applicationDirPath()/fonts/Ubuntu-R
Is the folder content with the ttf font. How do i set on my qt project?Any tips?
-
wrote on 20 Jun 2015, 04:14 last edited by Lays147
@JKSH @SGaist Well, i did this in my code in main.cpp
QString fontPath = ":/Fonts/Ubuntu-R.ttf";
int fontId = QFontDatabase::addApplicationFont(fontPath);
if (fontId != -1)
{
QFont font("MyFont");
app.setFont(font);
}It did works, but the error appears, this time only the first line terminal (Before appeared n times). But the program normally performs. Can anyone tell me why the error (FontDatabase) persist?
Ps.: I build my app with qt libraries STATIC. Exists another way to fix the font problem in the project without this way that i did?
2/2