Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Solved Font on Desktop is ok, on Anroid is too Big

    QML and Qt Quick
    5
    8
    646
    Loading More Posts
    • 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.
    • A
      athandev last edited by

      Hello, I'm new to QtQuick, I have this TableView

      Qtc1.TableView {
              width:parent.width
              height:parent.height*2/3
              id: products
             Qtc1.TableViewColumn {
                  role: "title"
                  title: "Title"
                  width: parent.width/2
              }
              Qtc1.TableViewColumn {
                  role: "cost"
                  title: "Cost"
                  width: parent.width/2
              }
                  /*onPressAndHold: {
                      mediator.removeItem(currentRow)
                  }*/
              model:mediator.myModel
      
          }
      

      This is the Desktop mode
      0_1528638707733_Screenshot_3.png

      And this is the Android Mode
      0_1528638733609_34879406_987284754773093_6305572599724244992_n.png

      1 Reply Last reply Reply Quote 0
      • A
        athandev last edited by

        Ok, I just add

        qputenv("QT_SCALE_FACTOR", "0.3");
        

        on my main.cpp

        1 Reply Last reply Reply Quote 1
        • A
          athandev last edited by

          Well now font's bad on Desktop, it's tiny, is there any way to know when app's running on Desktop or on Android, so I can run, or not run the command above?

          KillerSmath 1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            Did you forgot to disable QT_SCALE_FACTOR for desktop ?

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

            A 1 Reply Last reply Reply Quote 1
            • KillerSmath
              KillerSmath @athandev last edited by KillerSmath

              @athandev
              Did you try to use a preprocessor macro ?

              // main function
              
              ...
              
              #if defined(Q_OS_ANDROID)
               // do something on Android
              #elif defined(Q_OS_LINUX)
               // do something on Linux
              #endif
              
              ...
              

              @Computer Science Student - Brazil
              Web Developer and Researcher
              “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

              1 Reply Last reply Reply Quote 3
              • A
                athandev @SGaist last edited by

                How to do it?

                mrjj 1 Reply Last reply Reply Quote 0
                • mrjj
                  mrjj Lifetime Qt Champion @athandev last edited by

                  @athandev
                  You could just use defines as @KillerSmath shows.
                  and set QT_SCALE_FACTOR (or disable)
                  pr platform.

                  1 Reply Last reply Reply Quote 0
                  • I
                    igor_stravinsky last edited by

                    I have the same problem between desktops (Windows vs. Mac), so I use a set of dynamically defined constants, like this:

                    property int smallFontSize: (Qt.platform.os === "osx") ? 12 : 8;

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post