×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    14

    Exclamation Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    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
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    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
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    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
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    Yes...I am using Qt sdk 1.1.3.

  8. #8
    Registered User
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    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
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    Ok I go to look for it. Thank you.

  11. #11
    Registered User
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    I still cannot find the solution for it...

  12. #12
    Registered User
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    Change the values and then run again. see what happens.

  14. #14
    Registered User
    Join Date
    Oct 2011
    Posts
    14

    Re: Shake and change

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Shake and change

    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,

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
    Replies: 22
    Last Post: 2009-04-30, 09:58
  3. aXYZ module, Shake filter?
    By shynet in forum Symbian
    Replies: 7
    Last Post: 2008-12-27, 18:09
  4. N95 Shake
    By Rafael T. in forum Symbian
    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
  •  
×