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. How to change different fonts when change to different language.
Qt 6.11 is out! See what's new in the release blog

How to change different fonts when change to different language.

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.7k 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.
  • brucezcgB Offline
    brucezcgB Offline
    brucezcg
    wrote on last edited by
    #1

    I have 4 fonts:
    When UI language is English, use
    font1.ttf
    font2.ttf
    When language is Chinese, Use:
    font3.ttf
    font4.ttf

    How to do this? Thanks

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      After calling QApplication::installTranslator call QApplication::setFont

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      brucezcgB 1 Reply Last reply
      1
      • VRoninV VRonin

        After calling QApplication::installTranslator call QApplication::setFont

        brucezcgB Offline
        brucezcgB Offline
        brucezcg
        wrote on last edited by
        #3

        @VRonin Thanks, but I have 2 different ttf fonts each Language, app.setFont(xxx) only change the default font.
        For example:
        All title use bold.ttf,
        others use regular.ttf

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          There's no such a thing as a generic "title". What widgets are you using?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          brucezcgB 1 Reply Last reply
          0
          • VRoninV VRonin

            There's no such a thing as a generic "title". What widgets are you using?

            brucezcgB Offline
            brucezcgB Offline
            brucezcg
            wrote on last edited by
            #5

            @VRonin Sorry for not clearly expressed.
            For example:

            1. English Language:
              QTabBar{font:"Font1_English"}
              Default text {font:"Font2_English"}

            2)Chinese:
            Change QTabBar{font:"Font1_CN"}
            Default {font:"Font2_CN"}

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Are you using style sheet 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

              brucezcgB 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Are you using style sheet for that ?

                brucezcgB Offline
                brucezcgB Offline
                brucezcg
                wrote on last edited by
                #7

                @SGaist said in How to change different fonts when change to different language.:

                Yes SGaist

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then when the change language event happens, change the style sheet.

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

                  1 Reply Last reply
                  3

                  • Login

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