Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    I want to create a shake function using accelerometer method to change my list view item when i am shake, but I still cannot find the solution. Anyone can help me? It is urgent...

  2. #2
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    Download Qt SDK 1.1.3 available in the Qt page.

    You have to use the Sensor API (to get the sensor reading) from Qt mobility API :

    http://doc.qt.nokia.com/qtmobility-1.2/quickstart.html
    http://doc.qt.nokia.com/qtmobility-1.2/qml-sensor.html

    regards,

  3. #3
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    This is the part I want to use shake function. For now it only can use drag and change.

    import QtQuick 1.0
    import QtMultimediaKit 1.1
    import QtMobility.sensors 1.1





    Rectangle {
    id: rectangle1
    width: 360
    height: 640


    property int i: 0
    Accelerometer {
    active: true

    onReadingChanged: {

    if( reading.x>12|| reading.x<-12)
    {






    }else{
    }

    }




    }
    ListView {
    id: view
    anchors.fill: parent
    model: itemModel
    preferredHighlightBegin: 0; preferredHighlightEnd: 0
    highlightRangeMode: ListView.StrictlyEnforceRange
    orientation: ListView.Horizontal
    snapMode: ListView.SnapOneItem; flickDeceleration: 10000
    cacheBuffer: 200
    }


    VisualItemModel {
    id: itemModel

    Rectangle {
    id:rec1
    width: view.width; height: view.height
    color: "#F4F0FF"
    Text {
    id: page1
    text: "page1"
    }


    Component.onDestruction: print("destroyed 1")
    }

    Rectangle {
    id:rec2
    width: view.width; height: view.height
    color: "#F67008"
    Text {
    id: page1
    text: "page2"
    }


    Component.onDestruction: print("destroyed 2")
    }
    Rectangle {
    id:rec3
    width: view.width; height: view.height
    color: "#034621"
    Text {
    id: page1
    text: "page3"
    }

    }}
    Component.onDestruction: print("destroyed 3")



    }

  4. #4
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    Qt quick is used to create UI, for your Qt application, you want to change the song according to sensor reading, as I got.


    Code:
    onReadingChanged: {
    
    if( reading.x>12|| reading.x<-12)
    {
    
    
    
    
    
    
    }
    Write something in between this lines.

  5. #5
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    Yes..Actually I am new in this QT, and this code I refer the code from the the internet for shake and play the song. For now, what I want is, when I shake the phone, the list view will change to next page without drag it. You got what I mean?

  6. #6
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    I go the point,,there are many articles available inn the wiki (Qt wiki) for sensor .

    Are you using Qt SDK 1.1.3, so check the examples, and start learning, I would suggest don't start with Sensor example, but start learning with in built examples which are given with Qt SDK.

  7. #7
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    Yes...I am using Qt sdk 1.1.3.

  8. #8
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    Basically, I start learn this Qt a month a go. Now I got a project need to completed, and only this part is not completed yet.

  9. #9
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    Quote Originally Posted by vincent4443 View Post
    Basically, I start learn this Qt a month a go. Now I got a project need to completed, and only this part is not completed yet.
    Ok , try to do it according to the articles explanation. It is easy to do programming in Qt, as there are many articles and code tutorials are available,so .

    regards,

  10. #10
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    Ok I go to look for it. Thank you.

  11. #11
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    I still cannot find the solution for it...

  12. #12
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    Now my app can shake already.. But I am not using list view any more. Now the new problem is appear....the (reading.x>12|| reading.x<-12) can use?

  13. #13
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    Change the values and then run again. see what happens.

  14. #14
    Registered User vincent4443's Avatar
    Join Date
    Oct 2011
    Posts
    14
    I already change the value, but my app is still lagging on my phone when I shake too fast. When I use x>20|| x-20, the shake no action..so what is the maximum value ?

  15. #15
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,299
    I don't know which value is suitable for your code,, trial and error, is the best option.

    otherwise study this articles :

    http://doc.qt.nokia.com/qtmobility-1.2/sensors-api.html
    http://developer.qt.nokia.com/wiki/C...es_Sensors_API

    regards,

Page 1 of 2 12 LastLast

Similar Threads

  1. Handling shake in 5800 using accelerometer sensor
    By maymaria in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-05-04, 09:35
  2. What's the best way to handle a shake?
    By Rafael T. in forum Symbian C++
    Replies: 22
    Last Post: 2009-04-30, 09:58
  3. aXYZ module, Shake filter?
    By shynet in forum Python
    Replies: 7
    Last Post: 2008-12-27, 18:09
  4. N95 Shake
    By Rafael T. in forum Python
    Replies: 26
    Last Post: 2008-07-11, 04:35
  5. shake
    By billqu in forum Mobile Java General
    Replies: 1
    Last Post: 2004-08-02, 08:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved