[Qt-qml] Orientation listener

Ben Marinic ben at combinationstudios.com
Mon Aug 2 18:09:58 CEST 2010


Hi Joona.  Thanks for your help.  So I think I need to create a C++  
class which listens for the orientation changes, declare this class in  
my QML and then use signals so that my QML view can act upon these  
changes.  Is this correct?  I'm attempting to add a C++ class to my  
QML project in Qt Creator but get the following error:

Failed to add one or more files to project
'/Developer/source/Nokia/QtQuick/QMLTest/QMLTest.qmlproject' (/ 
Developer/source/Nokia/QtQuick/QMLTest/QMLTest/haptics.h).  I can see  
these files  (header and .cpp) in Finder in OS X but they don't show  
up in my projects tree.  Sorry - I'm completely new to QML/C++/Creator!

Thanks for any help
Ben

On 2 Aug 2010, at 08:13, <joona.t.petrell at nokia.com> <joona.t.petrell at nokia.com 
 > wrote:

> Hi Ben,
>
> QML Viewer provides a simple context property runtime.orientation  
> for listening to orientation changes on a device. It can update to  
> four different values: portrait, portrait inverted, landscape and  
> landscape inverted. Currently the property is updated on N900 and  
> Symbian S60 5.0 and newer devices. For more information, see http://doc.trolltech.com/4.7-snapshot/qmlviewer.html 
> .
>
> For more complex orientation handling, you are better off using  
> Sensor APIs from Qt Mobility:
> http://doc.trolltech.com/qtmobility-1.1-tp/sensors-api.html
>
> Qt Mobility teams are working on providing QML bindings for their  
> APIs:
> http://labs.trolltech.com/blogs/2010/07/27/qt-mobility-110-technology-preview/
>
> The QML syntax will be something like
>
> import QtMobility.sensors 1.1
>
> OrientationSensor {
>     active: true
>     onReadingChanged: {
>         console.log("New orientation: " + reading.orientation);
>     }
> }
>
> Cheers,
>
> Joona
>
> From: qt-qml-bounces at trolltech.com [mailto:qt-qml-bounces at trolltech.com 
> ] On Behalf Of ext Ben Marinic
> Sent: Thursday, July 29, 2010 7:16 PM
> To: qt-qml at trolltech.com
> Subject: [Qt-qml] Orientation listener
>
> Hi
>
> I need to listen for orientation changes in my QML view.   
> Specifically the following:  tilt right, tilt left, point up, point  
> down, tip forward, upwards and downwards.  I can see through some  
> old list serv threads that the syntax has changed a little over time  
> (binding to orientations).  What is the current method for listening  
> and executing a function on an orientation change in QML?
>
> Thanks
> Ben
>
> Ben Marinic
> Combination Studios Ltd
> e. ben at combinationstudios.com
> t. +44 (0)20 7193 2000
> m. +44 (0)7813 147 159
>
>
>
>
>

Ben Marinic
Combination Studios Ltd
e. ben at combinationstudios.com
t. +44 (0)20 7193 2000
m. +44 (0)7813 147 159





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100802/2b89206a/attachment.html 


More information about the Qt-qml mailing list