Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Segmentation fault
Forum Updated to NodeBB v4.3 + New Features

Segmentation fault

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 3 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kchandr7
    wrote on last edited by
    #1

    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);@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      You will either hit a segmentation fault or get an exit code. Which one is it? Do you have an backtrace?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kchandr7
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kchandr7
          wrote on last edited by
          #4

          Not sure if this will help. But I thought it was intuitive. Error is thrown when
          ui->textLable->setFont(UCFont); line is used.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AppsPat
            wrote on last edited by
            #5

            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?

            Stay Hungry. Stay Foolish.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kchandr7
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                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:-)

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kchandr7
                  wrote on last edited by
                  #8

                  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);@
                  
                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved