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. Android screen resolution problem[solved]
Forum Updated to NodeBB v4.3 + New Features

Android screen resolution problem[solved]

Scheduled Pinned Locked Moved Mobile and Embedded
21 Posts 4 Posters 19.8k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 10 Sept 2013, 03:30 last edited by
    #1

    Hi All,

    How can we set the screen size and the controls width and height in an Android device. The problem is that, i can run the same application in Windows and Android. But in Android the whole controls width and height changes.
    I think this may be due to the Android's screen resolution, but is there any way to fix this in Qt.

    Regards
    Ansif

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Adrien Leravat
      wrote on 10 Sept 2013, 15:17 last edited by
      #2

      Hi ansifpi,

      I guess you are using QtQuick and fixed size QML components ? As you are creating an application for multiple devices/screen, you will end up with different screen resolutions.

      You have at least three ways to deal with multi-resolution applications in QtQuick:

      • QtQuick Layouts, introduced in Qt 5.1.
      • Using anchors and/or relative width/height (i.e. "width: 0.8 * parent.width"). Always prefer contraining component size with anchors over fixed/relative size when possible.
      • Different main QML for each resolution: more expensive in time, and only relevant when having very different resolutions (like computer vs smartphone), but let you completly adapt your interface. This solutions will lead to better performances than the one above (dependents of your application size/type), as position/size doesn't need to be re-evalutated.

      The final solution will probably be a mix of those three elements

      Adeneo Embedded - www.adeneo-embedded.com

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on 11 Sept 2013, 07:20 last edited by
        #3

        Hi adrein,

        Thanks for the solution. I will try this and will update you soon.

        Ansif

        1 Reply Last reply
        0
        • N Offline
          N Offline
          niqt
          wrote on 12 Sept 2013, 07:16 last edited by
          #4

          how resolv it for the font size?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adrien Leravat
            wrote on 12 Sept 2013, 07:38 last edited by
            #5

            Hi niqt,

            You could do exactly the same for the font size, using font.pointSize or font.pixelSize.

            A short example using parent size
            @
            Text {
            id: text
            font.pointSize: parent.height / 4
            }
            @

            Note that this kind of expression will be re-evaluated each time the parent.height (in this case) changes. So it may impact performances if you have a lot of components with this kind of bindings.

            Adeneo Embedded - www.adeneo-embedded.com

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on 12 Sept 2013, 08:15 last edited by
              #6

              Hi,

              Different Android devices has different screen size's. Will the above solution works for all devices.

              Ansif

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Adrien Leravat
                wrote on 12 Sept 2013, 08:20 last edited by
                #7

                Sure it will, providing you resize the parent (in this case) appropriately, using layout, or relative size+positionning, or one QML for each resolution.

                When the application shows in full screen (automatically or by calling showFullScreen), it will fit the whole screen, no matter the size or resolution of it.

                Adeneo Embedded - www.adeneo-embedded.com

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on 12 Sept 2013, 09:31 last edited by
                  #8

                  [quote author="Adrien Leravat" date="1378974025"]Sure it will, providing you resize the parent (in this case) appropriately, using layout, or relative size+positionning, or one QML for each resolution.

                  When the application shows in full screen (automatically or by calling showFullScreen), it will fit the whole screen, no matter the size or resolution of it.[/quote]

                  Thank you
                  Ansif

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Adrien Leravat
                    wrote on 12 Sept 2013, 09:39 last edited by
                    #9

                    You're welcome. Please mark the thread's subject "[SOLVED]" if it solved your issue :)

                    Adeneo Embedded - www.adeneo-embedded.com

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on 12 Sept 2013, 09:42 last edited by
                      #10

                      I need to test some more features and i will update this post after that.

                      Regards
                      Ansif

                      1 Reply Last reply
                      0
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on 7 Oct 2013, 07:30 last edited by
                        #11

                        Its solved..

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vishu
                          wrote on 12 Dec 2013, 07:02 last edited by
                          #12

                          hai,, ansifpi,

                          I have the same problem.. but i used to use scale function for the app in qt 4.8 project which is available in qdeclarativeview class but its not available in qtquick2applicationsviewer , what to do. i used fixed size , i cant change the whole project , do you have any idea ? please...

                          1 Reply Last reply
                          0
                          • ? Offline
                            ? Offline
                            A Former User
                            wrote on 12 Dec 2013, 07:55 last edited by
                            #13

                            Hi vishu,

                            To be honest, i didnt try the above solution fully in my application. But I am sure that the solution above is good for all cases.
                            But check the latest Qt release, currently they are providing full support of Android development. Also there are some apps available for Android too, developed in Qt. I will check the links and will update you soon. Also just go through the latest Qt version and try some Android deployment, you can see the differences between your old and new versions.

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              vishu
                              wrote on 12 Dec 2013, 08:35 last edited by
                              #14

                              Hi, ansifpi

                              I installed Qt5.2 and i successfully ported qt4.8 project to Qt5.2 and deployed it in Android device, I met some troubles and resolved all but major is this resolution problem in we used qdeclarativeview and it has plenty of options. and even in Qt5.0 qtquick1apllicationviewer is inherited by qdeclarativeview but This qtquick2applicationviewer have really different hierarchy ,

                              Thanks

                              1 Reply Last reply
                              0
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on 12 Dec 2013, 09:20 last edited by
                                #15

                                Hey,
                                Use QQuickView instead of QDeclarativeview. QDeclarativeView is the old version usage, but in later Qt versions from Qt 5 we use QQuickView. I think you can easily change it to QQuickView, because most of the previous functions in QDeclarativeView is supported by it. For QtQuick 2.0 and latest libraries supports QQuickView. I think may be this will resolve the Android issue.

                                1 Reply Last reply
                                0
                                • V Offline
                                  V Offline
                                  vishu
                                  wrote on 12 Dec 2013, 09:22 last edited by
                                  #16

                                  Yes,
                                  Even i too decided the same,,
                                  Thanks.

                                  1 Reply Last reply
                                  0
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on 12 Dec 2013, 12:39 last edited by
                                    #17

                                    Please update me if your problem is solved. I will also need to test it for my application too.

                                    Regards

                                    1 Reply Last reply
                                    0
                                    • V Offline
                                      V Offline
                                      vishu
                                      wrote on 13 Dec 2013, 04:00 last edited by
                                      #18

                                      Yeah sure,

                                      Now what i am trying to do is, i will develop the application in Qt 4.8 and i will deploy it into the android device, previously i have done it.

                                      1 Reply Last reply
                                      0
                                      • ? Offline
                                        ? Offline
                                        A Former User
                                        wrote on 13 Dec 2013, 04:13 last edited by
                                        #19

                                        Hey,

                                        I suggest to work on the latest release, because Qt is much changed during these 2 year. In Current Qt version you can see some demos built for Android devices too. Qt 4.8 is a good version for PC's, but if you are looking for Android then its better to work on these latest versions.

                                        1 Reply Last reply
                                        0
                                        • V Offline
                                          V Offline
                                          vishu
                                          wrote on 13 Dec 2013, 04:24 last edited by
                                          #20

                                          You are correct,
                                          I got some lengthy solutions, i,e

                                          1. Changing my all qml files width and height and its child width and height , And i have to use as much as possible anchoring and relative width height, whenever the screen resolutions changes, this is very nasty because changing every width and height is not good idea, and especially handling elements with TextEdit, TextInput and Text is really difficult.
                                          2. designing new project for different resolutions , this is also bad idea,
                                          3. yet to find?
                                            if i get something really good idea.. i will tell you

                                          regards

                                          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