Android screen resolution problem[solved]



  • 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



  • 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



  • Hi adrein,

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

    Ansif



  • how resolv it for the font size?



  • 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.



  • Hi,

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

    Ansif



  • 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 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



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



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

    Regards
    Ansif



  • Its solved..



  • 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...



  • 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.



  • 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



  • 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.



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



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

    Regards



  • 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.



  • 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.



  • 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



  • Hi,
    Ok. Will see you later.

    Best of luck!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.