I have Qt Resource file (res.qrc) in my Qt Application. I imported my custom font in resource as below:
:/fonts/aa_marcus_east_syriac.ttf
Also i define in header file:
private:
QFont assyrianEventsAAMarcusEastSyriac;
I used QTextEdit in mainwindow. When user click on a button, my application read a text file. every row in text file should be imported in QTextEdit but some lines should be has aa_marcus_east_syriac.ttf font from my resource. So I wrote this codes:
void Widget::readMonthAssyrianEvents()
{
QStringList eventsList;
eventsList = readEventFile();
ui->notificationTextEdit->setCurrentFont(assyrianEventsAAMarcusEastSyriac);
for (int index = 0; index < eventsList.length(); index++)
{
QString eventType, eventContent;
QStringList tempStringList = eventsList[index].split('|');
eventType = tempStringList[0];
eventContent = tempStringList[1];
if (eventType == "0")
ui->notificationTextEdit->append(eventContent);
}
}
readEventFile() function works fine. It read text file and get all lines as QStringList. the "assyrianEventsAAMarcusEastSyriac" variable initialized in another function called init(). this is init() function:
int id = QFontDatabase::addApplicationFont(":/fonts/aa_marcus_east_syriac.ttf");
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
assyrianEventsAAMarcusEastSyriac.setFamily(family);
assyrianEventsAAMarcusEastSyriac.setPointSize(20);
My problem is that QTextEdit doesn't change font of it's contents to my custom font.
How can I solve this problem? Please help me guys. Thanks