Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML GPS
Qt 6.11 is out! See what's new in the release blog

QML GPS

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 3 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wilson_chan
    wrote on last edited by
    #1

    Hi, I am totally new to Qt symbian.

    May I ask how can I get GPS location data (longitude, latitude) in qml?

    Thank You.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Take a look at "mobility":http://doc.qt.nokia.com/qtmobility/qml-location-plugin.html.

      (Z(:^

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wilson_chan
        wrote on last edited by
        #3

        I have use the following code to get GPS location latitude and longitude.
        It seems work well in simulator Qt creator, but when I put it in phone it show "NaN".
        May I know what is the problem?

        @import QtQuick 1.1
        import QtMobility.location 1.2

        Rectangle {
        id: page
        width: 350
        height: 350
        PositionSource {
        id: positionSource
        updateInterval: 1000
        active: true
        }
        Column {
        Text {text: "<==== PositionSource ====>"}
        Text {text: "positioningMethod: " + printableMethod(positionSource.positioningMethod)}
        Text {text: "nmeaSource: " + positionSource.nmeaSource}
        Text {text: "updateInterval: " + positionSource.updateInterval}
        Text {text: "active: " + positionSource.active}
        Text {text: "<==== Position ====>"}
        Text {text: "latitude: " + positionSource.position.coordinate.latitude}
        Text {text: "longitude: " + positionSource.position.coordinate.longitude}
        Text {text: "altitude: " + positionSource.position.coordinate.altitude}
        Text {text: "speed: " + positionSource.position.speed}
        Text {text: "timestamp: " + positionSource.position.timestamp}
        Text {text: "altitudeValid: " + positionSource.position.altitudeValid}
        Text {text: "longitudeValid: " + positionSource.position.longitudeValid}
        Text {text: "latitudeValid: " + positionSource.position.latitudeValid}
        Text {text: "speedValid: " + positionSource.position.speedValid}
        }
        function printableMethod(method) {
        if (method == PositionSource.SatellitePositioningMethod)
        return "Satellite";
        else if (method == PositionSource.NoPositioningMethod)
        return "Not available"
        else if (method == PositionSource.NonSatellitePositioningMethod)
        return "Non-satellite"
        else if (method == PositionSource.AllPositioningMethods)
        return "All/multiple"
        return "source error";
        }
        }
        @

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Are you sure the GPS has locked? Maybe you just need to wait a minute or two for it to see the satellites. It's just a guess, though, I've never used QtMobility.

          (Z(:^

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wilson_chan
            wrote on last edited by
            #5

            Yeah I have wait for 5 minute already..

            The result come out as below :

            <====PositionSource====>
            positioningMethod :Satellite
            nmeaSource:
            updateInterval:1000
            active:true
            <====Position====>
            latitude:NaN
            longitude:NaN
            altitude:NaN
            speed:-1
            timestamp: Invalid Date
            altitudeValid: false
            longitudeValid: false
            latitudeValid: false
            speedValid: false

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              And does it work in any other app?

              (Z(:^

              1 Reply Last reply
              0
              • W Offline
                W Offline
                wilson_chan
                wrote on last edited by
                #7

                Sorry I have never try this in other apps. This is the first time I am trying to get GPS location data.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  I meant does GPS work in other apps, not necessarily written by you ;)

                  (Z(:^

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    wilson_chan
                    wrote on last edited by
                    #9

                    Yes. I think because I am getting this code from other website.

                    http://www.qtcentre.org/threads/41513-Get-GPS-Position-with-QML

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      amccarthy
                      wrote on last edited by
                      #10

                      Check that your application has declared the "Location" capability. You do this by adding the following to the applications .pro file:

                      symbian:TARGET.CAPABILITY += Location

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        wilson_chan
                        wrote on last edited by
                        #11

                        Hi amccarth,

                        I have put in below code inside the .pro file but it still cannot run.
                        symbian:TARGET.CAPABILITY += NetworkServices Location
                        CONFIG += mobility
                        MOBILITY += location

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved