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. Creating a form with the correct font for the host operating system.

Creating a form with the correct font for the host operating system.

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 3 Posters 822 Views 2 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I'm working on a project using Qt, the version of Qt and the compiler used is dictated by the client I'm contracted to:

    Qt Creator 4.4.1
    Based on Qt 5.9.2 (MSVC 2015, 32 bit)
    

    I would like to create a form that will always use the correct system font and size according to the host operating system it is running on.

    For the application I'm working on the host OS is Windows 10. I've chosen System Font, however the only sizes are 16 and 20 which doesn't look correct.

    I want the application and its forms to look like any other application running on the host, not like its been created with non-standard look and feel.

    When I drag a new label onto the form the default font used is [MS Shel DLL 2,8] which is very small compared to any font appearing in any other dialog used by other applications on the OS including Qt Creator.

    Is there a selection/setup within Qt Creator that will allow me to achieve selection of the default font and correct size?

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I'm working on a project using Qt, the version of Qt and the compiler used is dictated by the client I'm contracted to:

      Qt Creator 4.4.1
      Based on Qt 5.9.2 (MSVC 2015, 32 bit)
      

      I would like to create a form that will always use the correct system font and size according to the host operating system it is running on.

      For the application I'm working on the host OS is Windows 10. I've chosen System Font, however the only sizes are 16 and 20 which doesn't look correct.

      I want the application and its forms to look like any other application running on the host, not like its been created with non-standard look and feel.

      When I drag a new label onto the form the default font used is [MS Shel DLL 2,8] which is very small compared to any font appearing in any other dialog used by other applications on the OS including Qt Creator.

      Is there a selection/setup within Qt Creator that will allow me to achieve selection of the default font and correct size?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SPlatten said in Creating a form with the correct font for the host operating system.:

      Based on Qt 5.9.2 (MSVC 2015, 32 bit)

      Just a note: this is Qt version which was used to build QtCreator. Qt version you're using can be completely different...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SPlattenS 1 Reply Last reply
      0
      • jsulmJ jsulm

        @SPlatten said in Creating a form with the correct font for the host operating system.:

        Based on Qt 5.9.2 (MSVC 2015, 32 bit)

        Just a note: this is Qt version which was used to build QtCreator. Qt version you're using can be completely different...

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @jsulm , in the case of this project, its also the same version of Qt the company is using.

        Kind Regards,
        Sy

        1 Reply Last reply
        0
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #4

          @jsulm , I'm now creating a new UI, dropped a Push Button from the palette onto the mainwindow.ui, the button is very small and the font almost unreadable, yet this is using all the defaults, nothing has been modified.

          How to I get a button thats equal to the buttons as used by the dialogs in Qt Creator which look like they are the same size as every other button in the User Interface?

          Kind Regards,
          Sy

          mrjjM 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @jsulm , I'm now creating a new UI, dropped a Push Button from the palette onto the mainwindow.ui, the button is very small and the font almost unreadable, yet this is using all the defaults, nothing has been modified.

            How to I get a button thats equal to the buttons as used by the dialogs in Qt Creator which look like they are the same size as every other button in the User Interface?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @SPlatten
            Hi
            Are you on a hires screen?
            Does app look the same when you run it ?

            https://doc.qt.io/qt-5/highdpi.html

            SPlattenS 1 Reply Last reply
            0
            • mrjjM mrjj

              @SPlatten
              Hi
              Are you on a hires screen?
              Does app look the same when you run it ?

              https://doc.qt.io/qt-5/highdpi.html

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by SPlatten
              #6

              @mrjj , My screen is insane, its a 49" curved Samsung monitor, resolution is 5120x1140. No it doesn't look the same, without modifications, the button is smaller and not large enough for the font that was chosen by default. I have now resized the button and font, but I didn't think I would have to do this?

              Kind Regards,
              Sy

              mrjjM 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @mrjj , My screen is insane, its a 49" curved Samsung monitor, resolution is 5120x1140. No it doesn't look the same, without modifications, the button is smaller and not large enough for the font that was chosen by default. I have now resized the button and font, but I didn't think I would have to do this?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @SPlatten
                Ok so it is a hi def display.

                Read the link. there are some values you can try to tweak.

                How about Creator it self ? Does it look ok ?

                SPlattenS 1 Reply Last reply
                0
                • mrjjM mrjj

                  @SPlatten
                  Ok so it is a hi def display.

                  Read the link. there are some values you can try to tweak.

                  How about Creator it self ? Does it look ok ?

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #8

                  @mrjj , Qt Creator isn't a problem, I would have thought that regardless of the hardware being used that Qt Creator would use the same default OS settings?

                  Kind Regards,
                  Sy

                  mrjjM 1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @mrjj , Qt Creator isn't a problem, I would have thought that regardless of the hardware being used that Qt Creator would use the same default OS settings?

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @SPlatten
                    well im asking if it scales as it should ? buttons and menus etc are ok size ?
                    (not in the UI i mean, but the creator app itself)
                    Qt 5.9 is pretty old but i think hi res support came in 5.6
                    but been tweaked in later versions.

                    well normally one would put all buttons etc in layouts and when app run it should look "normal"
                    however, you should check if

                    int main(int argc, char *argv[])
                    {
                        QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // <-- enable it
                        QGuiApplication app(argc, argv);
                    

                    makes any difference.

                    SPlattenS 1 Reply Last reply
                    2
                    • mrjjM mrjj

                      @SPlatten
                      well im asking if it scales as it should ? buttons and menus etc are ok size ?
                      (not in the UI i mean, but the creator app itself)
                      Qt 5.9 is pretty old but i think hi res support came in 5.6
                      but been tweaked in later versions.

                      well normally one would put all buttons etc in layouts and when app run it should look "normal"
                      however, you should check if

                      int main(int argc, char *argv[])
                      {
                          QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // <-- enable it
                          QGuiApplication app(argc, argv);
                      

                      makes any difference.

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #10

                      @mrjj Thank you, but I'm not sure how this helps, because as I see it there are two problems here:

                      1. Qt Creator doesn't select the correct font by default when designing the WYSIWYG interface.
                      2. At runtime the font is different from that used when designing the interface.

                      Kind Regards,
                      Sy

                      mrjjM 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @mrjj Thank you, but I'm not sure how this helps, because as I see it there are two problems here:

                        1. Qt Creator doesn't select the correct font by default when designing the WYSIWYG interface.
                        2. At runtime the font is different from that used when designing the interface.
                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @SPlatten
                        Yep but its how it is with hi res display and fonts.
                        I highly recommend you read the link to gain an overview.

                        You might need to tweak the settings for it to look normal on that screen.

                        Must be nice with 5k desktop :)

                        SPlattenS 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @SPlatten
                          Yep but its how it is with hi res display and fonts.
                          I highly recommend you read the link to gain an overview.

                          You might need to tweak the settings for it to look normal on that screen.

                          Must be nice with 5k desktop :)

                          SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #12

                          @mrjj Thank you

                          Kind Regards,
                          Sy

                          mrjjM 1 Reply Last reply
                          0
                          • SPlattenS SPlatten

                            @mrjj Thank you

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @SPlatten
                            Oh i forgot to ask.
                            In windows 10. there is a text scale setting.
                            Often 150% or 200% for such screen.

                            What is your settings at ?

                            SPlattenS 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @SPlatten
                              Oh i forgot to ask.
                              In windows 10. there is a text scale setting.
                              Often 150% or 200% for such screen.

                              What is your settings at ?

                              SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by
                              #14

                              @mrjj I haven't changed it, just checked it's on 150% (Recommended).

                              Kind Regards,
                              Sy

                              mrjjM 1 Reply Last reply
                              0
                              • SPlattenS SPlatten

                                @mrjj I haven't changed it, just checked it's on 150% (Recommended).

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @SPlatten
                                ok. pretty normal value.

                                If you change it, does it affect how the buttons in the ui are ? I mean text size ?

                                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