Android screen resolution problem[solved]
-
wrote on 10 Sept 2013, 03:30 last edited by
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 -
wrote on 10 Sept 2013, 15:17 last edited by
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
-
wrote on 11 Sept 2013, 07:20 last edited by
Hi adrein,
Thanks for the solution. I will try this and will update you soon.
Ansif
-
wrote on 12 Sept 2013, 07:16 last edited by
how resolv it for the font size?
-
wrote on 12 Sept 2013, 07:38 last edited by
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.
-
wrote on 12 Sept 2013, 08:15 last edited by
Hi,
Different Android devices has different screen size's. Will the above solution works for all devices.
Ansif
-
wrote on 12 Sept 2013, 08:20 last edited by
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.
-
wrote on 12 Sept 2013, 09:31 last edited by
[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 -
wrote on 12 Sept 2013, 09:39 last edited by
You're welcome. Please mark the thread's subject "[SOLVED]" if it solved your issue :)
-
wrote on 12 Sept 2013, 09:42 last edited by
I need to test some more features and i will update this post after that.
Regards
Ansif -
wrote on 7 Oct 2013, 07:30 last edited by
Its solved..
-
wrote on 12 Dec 2013, 07:02 last edited by
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...
-
wrote on 12 Dec 2013, 07:55 last edited by
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. -
wrote on 12 Dec 2013, 08:35 last edited by
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
-
wrote on 12 Dec 2013, 09:20 last edited by
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. -
wrote on 12 Dec 2013, 09:22 last edited by
Yes,
Even i too decided the same,,
Thanks. -
wrote on 12 Dec 2013, 12:39 last edited by
Please update me if your problem is solved. I will also need to test it for my application too.
Regards
-
wrote on 13 Dec 2013, 04:00 last edited by
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.
-
wrote on 13 Dec 2013, 04:13 last edited by
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.
-
wrote on 13 Dec 2013, 04:24 last edited by
You are correct,
I got some lengthy solutions, i,e- 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.
- designing new project for different resolutions , this is also bad idea,
- yet to find?
if i get something really good idea.. i will tell you
regards