
Untitled
By: a guest on
Jun 27th, 2012 | syntax:
None | size: 1.08 KB | hits: 6 | expires: Never
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
location = new LocationWatcher();
if (location->source)
{
connect(location->source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
// ui->label->setText( QString("min %1").arg(location->source->minimumUpdateInterval()) );
}
}
LocationWatcher::LocationWatcher(QObject *parent)
: QObject(parent)
{
source = QGeoPositionInfoSource::createDefaultSource(this);
enabled = false;
if (source) {
source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods); //QGeoPositionInfoSource::SatellitePositioningMethods
source->setUpdateInterval(500); // this is the line that gives me trouble, so I just don't use it
}
}
void LocationWatcher::enable()
{
if (source) {
source->startUpdates();
enabled = true;
}
}
void LocationWatcher::disable()
{
if (source) {
enabled = false;
source->stopUpdates();
}
}