×
Namespaces

Variants
Actions
(Difference between revisions)

Retrieving satellite information in Qt

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
Line 1: Line 1:
__NOTOC__
+
{{ArticleMetaData <!-- v1.2 -->
__NOEDITSECTION__
+
{{ArticleMetaData
+
|id=
+
|platform=S60 5th Edition, Maemo 5
+
|devices=Nokia 5800 XpressMusic
+
|category=Qt
+
|subcategory=Qt Mobility
+
|creationdate=May 24, 2010
+
|keywords=
+
 
+
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia 5800 XpressMusic
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 5th Edition, Maemo 5
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Tapla]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20100525
 +
|author= [[User:Tapla]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Qt Mobility
 
}}
 
}}
  
Line 124: Line 129:
 
* http://doc.qt.nokia.com/qtmobility-1.0/location-overview.html
 
* http://doc.qt.nokia.com/qtmobility-1.0/location-overview.html
  
[[Category:Qt]][[Category:Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]][[Category:MeeGo Harmattan]] [[Category:Symbian]]
+
[[Category:Qt]][[Category:Qt Mobility]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:MeeGo Harmattan]] [[Category:Symbian]]

Revision as of 14:07, 23 July 2012

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition, Maemo 5
Symbian
Article
Created: tapla (25 May 2010)
Last edited: hamishwillee (23 Jul 2012)

Contents

Overview

This code snippet demonstrates how to retrieve satellite info in Qt using the Location module of Qt Mobility. It is assumed here that you have set up Qt Mobility in your development environment and on your device. For more information, see Setting up Qt Mobility.

Qt project file

Link the Location module into the project:

CONFIG += mobility
MOBILITY = location

Using the Location module requires the Location capability:

symbian: {
TARGET.CAPABILITY = Location
}

Header

#include <qgeosatelliteinfo.h>
#include <qgeosatelliteinfosource.h>
 
// QtMobility namespace
QTM_USE_NAMESPACE
 
class MainWindow : public QMainWindow
{
Q_OBJECT
 
public slots:
/**
* Called when the number of satellites in use is updated.
*/

void satellitesInUseUpdated(
const QList<QGeoSatelliteInfo> &satellites);
/**
* Called when the number of satellites in view is updated.
*/

void satellitesInViewUpdated(
const QList<QGeoSatelliteInfo> &satellites);
 
private:
/**
* Starts to monitor updates in the number of satellites.
*/

void startSatelliteMonitor();
 
private:
QGeoSatelliteInfoSource* satelliteInfoSource;
}

Source

void MainWindow::startSatelliteMonitor()
{
satelliteInfoSource =
QGeoSatelliteInfoSource::createDefaultSource(this);
 
// Whenever the satellite info source signals that the number of
// satellites in use is updated, the satellitesInUseUpdated function
// is called
QObject::connect(satelliteInfoSource,
SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)),
this,
SLOT(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)));
 
// Whenever the satellite info source signals that the number of
// satellites in view is updated, the satellitesInViewUpdated function
// is called
QObject::connect(satelliteInfoSource,
SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)),
this,
SLOT(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)));
 
// Start listening for satellite updates
satelliteInfoSource->startUpdates();
}
 
void MainWindow::satellitesInUseUpdated(
const QList<QGeoSatelliteInfo> &satellites) {
printString("The number of satellites in use is updated.");
}
 
void MainWindow::satellitesInViewUpdated(
const QList<QGeoSatelliteInfo> &satellites) {
printString("The number of satellites in view is updated");
}

Postconditions

Information about satellites in use and in view is retrieved.

See also

91 page views in the last 30 days.
×