Author

Topic: How to Change Font in Qt Wallets (Read 1203 times)

newbie
Activity: 38
Merit: 0
February 04, 2014, 02:16:19 PM
#1
Hello, hope you all are having a good day

Wondering how one changes the font in Bitcoin/Litecoin/Altcoin and set it to be used globally?

Add the font as a resource and your QRC file should look somthing like:
Code:

DejaVuSerif.ttf
DejaVuSerif-Bold.ttf
DejaVuSerif-BoldItalic.ttf
DejaVuSerif-Italic.ttf

and then add this to the main() function in bitcoin.cpp:

Code:
QStringList list;
list << "DejaVuSerif.ttf" << "DejaVuSerif-Bold.ttf" << "DejaVuSerif-Italic.ttf" << "DejaVuSerif-BoldItalic.ttf";
int fontID(-1);
bool fontWarningShown(false);
for (QStringList::const_iterator constIterator = list.constBegin(); constIterator != list.constEnd(); ++constIterator) {
QFile res(":/polices/" + *constIterator);
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 && fontWarningShown == false) {
QMessageBox::warning(0, "Application", (QString)"Impossible d'ouvrir la police " + QChar(0x00AB) + " DejaVu Serif " + QChar(0x00BB) + ".");
fontWarningShown = true;
}
}
}


Then after that, do :

Code:
QApplication.setFont(QFont("DejaVu Serif", 10));
to set it globally.

You're welcome.
Jump to: