qt - Change font of contents in QTextEdit from my application resource -
i have qt resource file (res.qrc) in qt application. imported custom font in resource below:
:/fonts/aa_marcus_east_syriac.ttf also define in header file:
private: qfont assyrianeventsaamarcuseastsyriac; i used qtextedit in mainwindow. when user click on button, application read text file. every row in text file should imported in qtextedit lines should has aa_marcus_east_syriac.ttf font resource. wrote codes:
void widget::readmonthassyrianevents() { qstringlist eventslist; eventslist = readeventfile(); ui->notificationtextedit->setcurrentfont(assyrianeventsaamarcuseastsyriac); (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. read text file , lines qstringlist. "assyrianeventsaamarcuseastsyriac" variable initialized in function called init(). 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 qtextedit doesn't change font of it's contents custom font.
how can solve problem? please me guys. thanks
i think error in
qstring family = qfontdatabase::applicationfontfamilies(id).at(0); have checked .at(0) custom font ?
most can solve calling assyrianeventsaamarcuseastsyriac.setfamily explicit string of font family like
assyrianeventsaamarcuseastsyriac.setfamily("marcus east syriac"); if doesn't work either, maybe custom font malformed or doesn't provide font family name. therefore suggest try first working font , go custom stuff.
Comments
Post a Comment