Segmentation fault
-
I'm trying to load a custom ttf font. And whenever I hit run I get a Segmentation Fault and with Exit code 139. Any help is appreciated!
@
QFontDatabase *UniCon =new QFontDatabase;
UniCon->addApplicationFont(":/files/fonts/ufonts.com_universal-condensed.ttf");
QFont UCFont;
UCFont=UniCon->font("Universal Condensed","Regular",80);@ -
You will either hit a segmentation fault or get an exit code. Which one is it? Do you have an backtrace?
-
Both, this is what I get in the application output in Qt Creator.
Killing remote process(es)...
Starting remote process ...
Remote process started.
Segmentation fault
Finished running remote process. Exit code was 139.Not sure what you mean by a backtrace, I'm new to both Linux and Qt.
-
Not sure if this will help. But I thought it was intuitive. Error is thrown when
ui->textLable->setFont(UCFont); line is used. -
Are you assigning the font in the same method?
Have you thought about, that the UCFont will be deleted when leaving the method?Just some ideas, can you provide some more rows of your code?
-
Well, I've avoided the error. But now, the font doesn't seem to apply. I avoided the error by placing
ui->setupUi(this); before I applied the font. -
What are you running your code on? Which Qt version do you use?
Is UCFont valid after the line 4 of your code? It might try to render your UI without any font set up if it is not.
Setting the font after the UI is drawn might avoid your issue, but it will of course not result in what you want to see:-)
-
I am running on Embedded Linux. Qt Version 4.7.2
Observed behavior is the text in the label becomes really small and it doesn't seem like the font is applying.
@ ui->setupUi(this);
QFontDatabase *UniCon =new QFontDatabase;
UniCon->addApplicationFont(":/files/fonts/ufonts.com_universal-condensed.ttf");
QFont UCFont;
UCFont=UniCon->font("Universal Condensed","Regular", 120);ui->TempLabel->setFont(UCFont);@