Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to change font size at the application?
Forum Updated to NodeBB v4.3 + New Features

How to change font size at the application?

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 3 Posters 24.5k 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.
  • M Offline
    M Offline
    maxim.prishchepa
    wrote on last edited by
    #1

    I need change font size at the application, for example: at the settings user can choose: small, medium or large font size, how to dinamical change a font size at the all of application windows?

    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hi
      Using QFontDialog
      "Font Dialog":http://qt-project.org/doc/qt-5/qfontdialog.html

      Be Cute

      1 Reply Last reply
      0
      • IamSumitI Offline
        IamSumitI Offline
        IamSumit
        wrote on last edited by
        #3

        Hi
        in addition to answer of 2nd Question
        "QApplication":http://qt-project.org/doc/qt-5/qapplication.html#setFont

        hope it helps.

        Be Cute

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxim.prishchepa
          wrote on last edited by
          #4

          Tnx 4 answers!
          About QApplication::setFont - i know that method, but when i set the font using it - nothing happend :( font still the same as was.

          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

          1 Reply Last reply
          0
          • IamSumitI Offline
            IamSumitI Offline
            IamSumit
            wrote on last edited by
            #5

            The behavior of fonts vary from OS to OS.
            Did you pass second parameter as class in QApplication::setFont.?

            Be Cute

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxim.prishchepa
              wrote on last edited by
              #6

              nope, only put font object to the method.
              i test at the linux, mac and android - nothing changed.
              about second arg - i need change font size at the all of ui object.

              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

              1 Reply Last reply
              0
              • IamSumitI Offline
                IamSumitI Offline
                IamSumit
                wrote on last edited by
                #7

                Hi
                Please pass second argument as well.
                For eample if you want to change font of all QWidget then pass "QWidget"

                Be Cute

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maxim.prishchepa
                  wrote on last edited by
                  #8

                  emmm..... ok maybe some one know base container name for qml elements? :)

                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #9

                    Hi,

                    [quote author="Maxim Prishchepa" date="1412776706"]nope, only put font object to the method.
                    i test at the linux, mac and android - nothing changed.
                    about second arg - i need change font size at the all of ui object.[/quote]

                    Which Qt version are you using ? The below code works for me:
                    @
                    QGuiApplication app(argc, argv);
                    QFont f = app.font();
                    f.setFamily("Monaco");
                    f.setPointSize(32);
                    app.setFont(f);
                    QQuickView view;
                    ...
                    @

                    157

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      maxim.prishchepa
                      wrote on last edited by
                      #10

                      Hi p3c0!
                      Tnx 4 answer!
                      I use Qt 5.3.2.

                      About your code: i should give to user posibility to chenge font on runtime, when QQuickView object is already created.
                      As options: check recurcive all child object at the QQuickView container, but it's take a time :( maybe some other options?

                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #11

                        Well then Binding is your friend here. Create a global variable for eg:
                        @
                        property real appfontSize: 12.0
                        @

                        Then bind this property to all other components font.pointSize wherever applicable and when the user chooses a font size, change appfontSize to new size and thus will change binded components font size.

                        157

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          maxim.prishchepa
                          wrote on last edited by
                          #12

                          p3c0 - tnx 4 answer, i'll try it.

                          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

                          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