View Single Post
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#3
Well, when it does not work I don't get any signal about it being done. And I don't see the location icon blinking in the status bar.

Here is my locationing code, maybe a bit hacky, but it works.. (without fullscreen mode):
Maybe somebody got a simpler code for me to use?
Code:
#include "gps.h"

#include <qgeopositioninfosource.h>
#include <qnmeapositioninfosource.h>
#include <qgeosatelliteinfosource.h>
#include <QTimer>
#include <QDebug>


GPS::GPS(QObject *parent) :
    QObject(parent),
    location(0),
{
}


void GPS::start()
{
    location = QGeoPositionInfoSource::createDefaultSource(this);

    location->setUpdateInterval(5000);


    connect(location, SIGNAL(positionUpdated(QGeoPositionInfo)),
            this, SLOT(positionUpdated(QGeoPositionInfo)));


    location->startUpdates();
}

void GPS::positionUpdated(const QGeoPositionInfo &info)
{


     latitude = info.coordinate().latitude();
     longitude = info.coordinate().longitude();

     emit getOK_GPS();


}

Last edited by tmsha; 2010-06-30 at 20:41.