Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Font changes not aplying
Forum Update on Monday, May 27th 2025

Font changes not aplying

Scheduled Pinned Locked Moved Solved General and Desktop
fonteglfs rpi2raspberry pi 2
16 Posts 3 Posters 6.5k Views
  • 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.
  • C Offline
    C Offline
    cxam
    wrote on 25 Mar 2016, 22:11 last edited by
    #1

    Hi I'm cross compiling on raspberry pi 2 but I can't seem to change the font, it always stays a regular font which I think it's arial. I've tried selecting different fonts but nothing.

    Stay Hungry, Stay Foolish

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Mar 2016, 23:51 last edited by
      #2

      Hi,

      Do you have the fonts you want to work with available on your Pi2 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 26 Mar 2016, 07:17
      0
      • S SGaist
        25 Mar 2016, 23:51

        Hi,

        Do you have the fonts you want to work with available on your Pi2 ?

        C Offline
        C Offline
        cxam
        wrote on 26 Mar 2016, 07:17 last edited by
        #3

        @SGaist Of Course, the font in particular is "Open Sans" so I downloades from the same site the one I installed in the computer and the one I intalled on the pi but nothing.

        Stay Hungry, Stay Foolish

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Mar 2016, 21:11 last edited by
          #4

          Did you check that the application can find it ? QFontDatabase comes to mind for that.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply 26 Mar 2016, 23:13
          0
          • S SGaist
            26 Mar 2016, 21:11

            Did you check that the application can find it ? QFontDatabase comes to mind for that.

            C Offline
            C Offline
            cxam
            wrote on 26 Mar 2016, 23:13 last edited by
            #5

            @SGaist said:

            QFontDatabase

            So What I did using QFontDatabase:

            QFontDatabase::addApplicationFont( "/usr/share/fonts/truetype/Open_Sans/OpenSans-Regular.ttf");
            

            But nothing happened, so I checked that the font was currently installed using

            fc-list
            

            And indeed, it was installed but I don't know why not recognized by Qt.

            Stay Hungry, Stay Foolish

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 27 Mar 2016, 00:10 last edited by
              #6

              Did you check the returned id from addApplicationFont ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply 27 Mar 2016, 12:11
              0
              • S SGaist
                27 Mar 2016, 00:10

                Did you check the returned id from addApplicationFont ?

                C Offline
                C Offline
                cxam
                wrote on 27 Mar 2016, 12:11 last edited by
                #7

                @SGaist More or less, what I did to test that the font is working is this:

                int id = QFontDatabase::addApplicationFont( "/usr/share/fonts/truetype/Open_Sans/OpenSans-Regular.ttf");
                QString family = QFontDatabase::applicationFontFamilies(id).at(0);
                QFont monospace(family);
                qApp->setFont(monospace);
                

                But it doesn't work.... No idea what can be happening

                Stay Hungry, Stay Foolish

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 27 Mar 2016, 20:38 last edited by
                  #8

                  What is the value of id ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  C 1 Reply Last reply 27 Mar 2016, 21:26
                  0
                  • S SGaist
                    27 Mar 2016, 20:38

                    What is the value of id ?

                    C Offline
                    C Offline
                    cxam
                    wrote on 27 Mar 2016, 21:26 last edited by
                    #9

                    @SGaist I'm trying to show the value of the "id" variable through QDebug and the Application output but it's not showing.

                    Stay Hungry, Stay Foolish

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 27 Mar 2016, 21:46 last edited by
                      #10

                      Use the debugger then or a dummy widget.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      C 1 Reply Last reply 28 Mar 2016, 10:15
                      0
                      • S SGaist
                        27 Mar 2016, 21:46

                        Use the debugger then or a dummy widget.

                        C Offline
                        C Offline
                        cxam
                        wrote on 28 Mar 2016, 10:15 last edited by
                        #11

                        @SGaist Ok, I wasn't pressing the "Debug" button haha, anyways I've found that the "id" value is 0.

                        Stay Hungry, Stay Foolish

                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 28 Mar 2016, 10:30 last edited by
                          #12

                          @cxam said:
                          hi, just small question.
                          Since addApplicationFont dont return -1 for error, i wonder if he need to NEW the font as they talk about here
                          https://forum.qt.io/topic/23875/how-to-use-qfontdatabase-addapplicationfont
                          ?

                          C 2 Replies Last reply 28 Mar 2016, 10:58
                          1
                          • mrjjM mrjj
                            28 Mar 2016, 10:30

                            @cxam said:
                            hi, just small question.
                            Since addApplicationFont dont return -1 for error, i wonder if he need to NEW the font as they talk about here
                            https://forum.qt.io/topic/23875/how-to-use-qfontdatabase-addapplicationfont
                            ?

                            C Offline
                            C Offline
                            cxam
                            wrote on 28 Mar 2016, 10:58 last edited by
                            #13

                            @mrjj said:

                            https://forum.qt.io/topic/23875/how-to-use-qfontdatabase-addapplicationfont

                            I think that's the answer to my problem but I'm unable to put it into my program, would you mind making it more explained for me please?

                            Stay Hungry, Stay Foolish

                            1 Reply Last reply
                            0
                            • mrjjM mrjj
                              28 Mar 2016, 10:30

                              @cxam said:
                              hi, just small question.
                              Since addApplicationFont dont return -1 for error, i wonder if he need to NEW the font as they talk about here
                              https://forum.qt.io/topic/23875/how-to-use-qfontdatabase-addapplicationfont
                              ?

                              C Offline
                              C Offline
                              cxam
                              wrote on 28 Mar 2016, 11:06 last edited by
                              #14

                              @mrjj Ok, I've got it. Thank you for your help :)

                              Stay Hungry, Stay Foolish

                              mrjjM 1 Reply Last reply 28 Mar 2016, 11:07
                              0
                              • C cxam
                                28 Mar 2016, 11:06

                                @mrjj Ok, I've got it. Thank you for your help :)

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 28 Mar 2016, 11:07 last edited by
                                #15

                                @cxam
                                so did it make any difference?

                                C 1 Reply Last reply 28 Mar 2016, 11:16
                                0
                                • mrjjM mrjj
                                  28 Mar 2016, 11:07

                                  @cxam
                                  so did it make any difference?

                                  C Offline
                                  C Offline
                                  cxam
                                  wrote on 28 Mar 2016, 11:16 last edited by
                                  #16

                                  @mrjj Yes, What I did was

                                  QFontDatabase::addApplicationFont("/usr/share/fonts/truetype/Open_Sans/OpenSans-Regular.ttf");
                                  

                                  and then select "Open Sans" on the QtDesigner

                                  Stay Hungry, Stay Foolish

                                  1 Reply Last reply
                                  1

                                  1/16

                                  25 Mar 2016, 22:11

                                  • Login

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