Two QmlApplicationViewers in an application
I want to lock screen orientation on Portrait for some qml pages and lock it on Landscape for another qml pages. I didn't find a way to do it in QML.
So here is my solution:
I create 2 QmlApplicationViewers in the main.cpp, one is locked on Portrait and the other is locked on Landscape:
I also got some signals and slots to swith between those viewers. I thought this method should work. But a problem appears:
the application is just take the view2's orientation into account. the two views seem to use the same orientation setting.
My question is: how to solve this problem or anyone has other ideas to lock orientation for specific QML pages?
is it possible to set screen orientation on the fly?
Why don't just read the accelerometers by yourself?
@minimoog77, thanks for your suggestion, But i didn't find a way to lock screen orientation using accelerometers, could you please explain it more?
You will lock the orientation. Then you will use accelerometers to detect if it's orientation was changed, and you will manually orient the qml elements.
But, why do you want locking the orientation both ways?
@minimoog77, i want to do it because, in my appli, there is a video player, i have to set it on Landscape, and for other QML pages, i want to locked it on portrait.
you mean for the QmlApplicationViewer, l locke the application on portrait, and use accelerometers or orientation sensor to set orientation for video page?
Yes, that was the idea, if you want full control of orientation.
@minimoog77 ,but i can imagine, if i lock the application on portrait, all pages are locked on portait. Video page is included, i can use sensors to get orientation's changing signals to change qml elements' properties (width, height...etc), but i can't set orientation on Landscape. isn't it ?
You can rotate video page according to sensors.
is it possible QmlApplicationViewer can be used or manipulated in other class rather than main;
rishygupta, you have asked this question in a number of threads, a couple of which are very old. Please open a separate thread for a new question and please don't duplicate your questions. Thanks.