Retrieving satellite information in Qt
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot update - Add ArticleMetaData) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| Line 47: | Line 47: | ||
==Header== | ==Header== | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <qgeosatelliteinfo.h> | #include <qgeosatelliteinfo.h> | ||
#include <qgeosatelliteinfosource.h> | #include <qgeosatelliteinfosource.h> | ||
| Line 83: | Line 83: | ||
==Source== | ==Source== | ||
| − | <code cpp> | + | <code cpp-qt> |
void MainWindow::startSatelliteMonitor() | void MainWindow::startSatelliteMonitor() | ||
{ | { | ||
Latest revision as of 04:18, 11 October 2012
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition, Maemo 5
Article
Created: tapla
(25 May 2010)
Last edited: hamishwillee
(11 Oct 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.

