Can Qt Quick response to the screen rotation (Symbian)?
-
Anyone know how to acheive the following screen rotation response using QML on Symbian?
-
In landscape screen , showing image file of "image1"
-
After rotating to portrait screen, the showing picture change to "image2"
I did some searching, the following thread have some clues and written in C++ rather than QML.
http://developer.qt.nokia.com/forums/viewthread/1452 -
-
QML cannot detect orientation change on its own yet.
-
Just find an example about screen orientation, but seems not ideal one for symbian.
http://doc.qt.nokia.com/4.7-snapshot/declarative-screenorientation-screenorientation-qml.html -
You can write orientation changing listener in C++ and use Connections in QML to listen for signal from object that will do it in C++.
-
Using Symbian C++ it is possible to listen to orientation changes. However, AFAIK its not possible to detect that in QML without using C++.
-
QtK, you can do it in pure Qt using QDesktopWidget, it has signal for desktop size changing.
-
It's not using QML right.
Also in case of QDesktopWidget are you referring to any of these signals.
@void resized ( int screen )
void screenCountChanged ( int newCount )
void workAreaResized ( int screen )@ -
QtK, I'm saying about resized(), right.
-
Found more docs about orientation.
My understanding of the this doc, if we intalled qmlviewer on Symbian device, and load the qml file using qmlviewer, orientation should able to be detected at run timehttp://doc.qt.nokia.com/4.7-snapshot/qmlviewer.html
QML applications that are loaded with the QML Viewer have access to a special runtime property on the root context. This property provides additional information about the application's runtime environment through the following properties:
runtime.orientation
This property indicates the current orientation of the QML Viewer. On the N900 platform and most S60 5.0-based or newer Symbian devices, this property automatically updates to reflect the device's actual orientation; on other platforms, this indicates the orientation currently selected in the QML Viewer's Settings -> Properties menu. The orientation value can be one of the following:- Orientation.Portrait
- Orientation.Landscape
- Orientation.PortraitInverted (Portrait orientation, upside-down)
- Orientation.LandscapeInverted (Landscape orientation, upside-down)
When the viewer's orientation changes, the appearance of the loaded QML document does not change unless it has been set to respond to changes in runtime.orientation. For example, the following Rectangle changes its aspect ratio depending on the orientation of the QML Viewer:
@
Rectangle {
id: window
width: 640; height: 480states: State { name: "landscape" PropertyChanges { target: window; width: 480; height: 640 } } state: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 'landscape' : ''
} @
-
I came up with a little bit of a solution for this. I have an image that I wanted to go away when in landscape but still needed its height for calculations in other blocks. The key for this process to work is I have one block containing the whole program called
@
id:wholeBlock
@This block adjusts to the size of the screen so for the height of the image I put in.
@
height: wholeBlock.width>wholeBlock.height ? 0 : 200
@So if the width is greater than the height of the whole screen it sets the size to 0 or on the flip it sets it to 200. Hope this little bit of trickery can help someone out.