SatelliteInfo (QML)

The SatelliteInfo example shows the available satellites using Sky View or RSSI View and the user's current position. The satellites currently contributing to the GPS fix are marked as pink.

This example demonstrates the usage of Qt Positioning QML API:

The example shows satellite information in two different tabs. The data is taken from the SatelliteSource::satellitesInView and SatelliteSource::satellitesInUse properties.

The Sky View tab shows the relative satellite positions using the Azimuth and Elevation attributes.

The RSSI View tab shows the signal strength of satellites in view using the signalStrength property.

In both cases, the displayed numbers are the individual satellite identifiers. The satellites that are currently used to calculate the GPS fix are marked pink.

The Current Position block below the satellite information uses PositionSource::position property to show the current latitude and longitude.

The Status block shows the current mode or the last error.

The application operates in three different modes:

Application modeDescription
RunningThe application continuously queries the system for satellite and position updates. When new data is available it will be displayed.
StoppedThe application stops updating the satellite and position information.
SingleThe application makes a single satellite and position update request.

The application automatically switches into a simulation mode if the platform does not provide satellite or position information. The simulation mode uses an NMEA plugin with pre-recorded NMEA data.

Note: Apple does not provide any APIs to retrieve satellite information, so on macOS and iOS the satellite information will always be taken from pre-recorded data. These API limitations do not affect positioning information, so current position can be displayed correctly.

Running the Example

To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.

Retrieving Current Position

The current position is retrieved from the PositionSource QML object. The onPositionChanged handler is used to receive position updates. The string representations of latitude and longitude are extracted from the coordinate property.

PositionSource {
    id: positionSource
    name: root.simulation ? "nmea" : ""
    onPositionChanged: {
        let posData = position.coordinate.toString().split(", ")
        positionAndStatus.latitudeString = posData[0]
        positionAndStatus.longitudeString = posData[1]
    }
}

Retrieving Satellite Information

Similarly to the position, the current satellite information is retrieved from the SatelliteSource QML object. The onSatellitesInViewChanged and onSatellitesInUseChanged handlers are used to get the updated satellites in view and satellites in use respectively. The data is then combined into a single model, which is passed to both Sky View and RSSI View tabs.

SatelliteSource {
    id: satelliteSource
    name: root.simulation ? "nmea" : ""
    onSatellitesInViewChanged: root.updateModel()
    onSatellitesInUseChanged: {
        root.inUseIds.clear()
        for (var i = 0; i < satellitesInUse.length; ++i)
            root.inUseIds.add(satellitesInUse[i].satelliteIdentifier)

        root.updateModel()
    }
}

QML Module Registration

CMake Build

For a CMake-based build, we need to add the following to the CMakeLists.txt:

qt_add_qml_module(satelliteinfo
    URI SatelliteInformation
    VERSION 1.0
    QML_FILES
        Button.qml
        Main.qml
        RssiView.qml
        PositionAndStatus.qml
        SkyView.qml
        ViewSwitch.qml
)
qmake Build

For a qmake build, we need to modify the satelliteinfo.pro file in the following way:

qml_resources.files = \
    qmldir \
    Button.qml \
    Main.qml \
    RssiView.qml \
    PositionAndStatus.qml \
    SkyView.qml \
    ViewSwitch.qml

qml_resources.prefix = /qt/qml/SatelliteInformation

RESOURCES += qml_resources

Example project @ code.qt.io

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.