Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 6.9.1 Android screen scale factor issues.
Forum Updated to NodeBB v4.3 + New Features

Qt 6.9.1 Android screen scale factor issues.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
11 Posts 3 Posters 318 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.
  • SMF-QtS Offline
    SMF-QtS Offline
    SMF-Qt
    wrote last edited by SMF-Qt
    #1

    I am trying to understand what is and what is not possible in terms of screen scaling and presentation with applications witten using qmake, designer and C++.
    I have just setup a development environment using qtcreator (17), jdk-24.0.1, qt-6.9.1 gradle (8.14), sdk(19) and ndk (27.2.12479018) and have ported one of my projects to this setup as a test application.

    My application has migrated quite well, my biggest problem currently is the the way the app presents itself on different targets.
    I am currently testing on an X86_64 simulator phone, Samsung A06 phone, Samsung Tab9 tablet and an HTC 2022 pro phone.
    They all look and behave slightly different the Tab9 being the best with the test app nicely centered (in landscape) on the screen with very little wasted space above and the below.
    The A06 is the worst with the app falling off the bottom left of the screen (again in landscape). Things tend to fall apart on all devices if the device is in portrait mode.

    As a starting point I have used the following after a Google trawl, I am hoping there is a better way to take control of my apps look and feel.

    int main(int argc, char *argv[])
    {
    QApplication *app=new QApplication(argc, argv);
    QScreen *sc=app->primaryScreen();
    qreal ratio=1.0/(sc->devicePixelRatio());
    qputenv("QT_SCALE_FACTOR", QString::number(ratio).toLocal8Bit());
    qputenv("QT_AUTO_SCREEN_SCALE_FACTOR","0");
    delete app;
    app = new QApplication(argc, argv);
    ...
    }

    Any suggestions welcome.

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote last edited by
      #2

      Is the Android version same on all devices?

      SMF-QtS 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        Is the Android version same on all devices?

        SMF-QtS Offline
        SMF-QtS Offline
        SMF-Qt
        wrote last edited by
        #3

        @JoeCFD

        No the Simulator and Tablet are15 the A06 is 14 and the HTC 12.

        JoeCFDJ 1 Reply Last reply
        0
        • SMF-QtS SMF-Qt

          @JoeCFD

          No the Simulator and Tablet are15 the A06 is 14 and the HTC 12.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote last edited by JoeCFD
          #4

          @SMF-Qt Maybe you can try to downgrade jdk and sdk versions for Android 14 and 12. Be aware that there is compatibility issue among these packages. You can go through my posts to find that out.

          1 Reply Last reply
          0
          • SMF-QtS Offline
            SMF-QtS Offline
            SMF-Qt
            wrote last edited by
            #5

            Thank you for your comment. During my journey to set up an android build enviromment I tried various combinations of build tool versions the set I am currently using produces working apk files for my selected set of deployment targets.

            JoeCFDJ 1 Reply Last reply
            0
            • SMF-QtS SMF-Qt

              Thank you for your comment. During my journey to set up an android build enviromment I tried various combinations of build tool versions the set I am currently using produces working apk files for my selected set of deployment targets.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote last edited by
              #6

              @SMF-Qt I used Qt5 + old versions of sdk and jdk and did not have your issue on Tablet and Phone with Android 12/13/14.

              SMF-QtS 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @SMF-Qt I used Qt5 + old versions of sdk and jdk and did not have your issue on Tablet and Phone with Android 12/13/14.

                SMF-QtS Offline
                SMF-QtS Offline
                SMF-Qt
                wrote last edited by
                #7

                @JoeCFD

                Thanks for the insight but my path is qt6 and that is my focus.

                1 Reply Last reply
                0
                • SMF-QtS Offline
                  SMF-QtS Offline
                  SMF-Qt
                  wrote last edited by SMF-Qt
                  #8

                  I am currently trying to find a c++ programmatic method for locking my application into landscape mode.
                  I have seen on the web various methods (including copying and hacking build xml files) to acheive this but so far nothing constructive that support my Qt6 setup.
                  I have found "setRequestedOrientation" references in various java files under the sdk and I know there was a Qt5 method for accessing it but nothing currently in Qt6.

                  Any suggestions welcome.

                  ekkescornerE 1 Reply Last reply
                  0
                  • SMF-QtS SMF-Qt

                    I am currently trying to find a c++ programmatic method for locking my application into landscape mode.
                    I have seen on the web various methods (including copying and hacking build xml files) to acheive this but so far nothing constructive that support my Qt6 setup.
                    I have found "setRequestedOrientation" references in various java files under the sdk and I know there was a Qt5 method for accessing it but nothing currently in Qt6.

                    Any suggestions welcome.

                    ekkescornerE Offline
                    ekkescornerE Offline
                    ekkescorner
                    Qt Champions 2016
                    wrote last edited by
                    #9

                    @SMF-Qt said in Qt 6.9.1 Android screen scale factor issues.:

                    I am currently trying to find a c++ programmatic method for locking my application into landscape mode.

                    you can try

                    bool ApplicationUI::setScreenOrientationLandscape()
                    {
                        QJniObject activity = QNativeInterface::QAndroidApplication::context();
                    
                        if(activity.isValid())
                        {
                            activity.callMethod<void>("setRequestedOrientation", "(I)V", 0);
                            return true;
                        }
                    
                        return false;
                    }
                    

                    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                    5.15 --> 6.9 https://t1p.de/ekkeChecklist
                    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                    SMF-QtS 1 Reply Last reply
                    3
                    • ekkescornerE ekkescorner

                      @SMF-Qt said in Qt 6.9.1 Android screen scale factor issues.:

                      I am currently trying to find a c++ programmatic method for locking my application into landscape mode.

                      you can try

                      bool ApplicationUI::setScreenOrientationLandscape()
                      {
                          QJniObject activity = QNativeInterface::QAndroidApplication::context();
                      
                          if(activity.isValid())
                          {
                              activity.callMethod<void>("setRequestedOrientation", "(I)V", 0);
                              return true;
                          }
                      
                          return false;
                      }
                      
                      SMF-QtS Offline
                      SMF-QtS Offline
                      SMF-Qt
                      wrote last edited by
                      #10

                      @ekkescorner

                      Thank you that worked.

                      ekkescornerE 1 Reply Last reply
                      0
                      • SMF-QtS SMF-Qt

                        @ekkescorner

                        Thank you that worked.

                        ekkescornerE Offline
                        ekkescornerE Offline
                        ekkescorner
                        Qt Champions 2016
                        wrote last edited by
                        #11

                        @SMF-Qt cool :)

                        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                        5.15 --> 6.9 https://t1p.de/ekkeChecklist
                        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                        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