×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    29

    QGeoPositionInfoSource problem. I tried everything I could.

    Hi.

    I want to know the GPS coordinates of the cellphone's current location.

    Accuracy is not important to me so any possible method to aquire the location is accepted as long as it is availabe in Qt.

    I read the wikis and articles regarding this and also searched the forums for such problems but couldn't find anything that helps my program.

    I downloaded some example in one of the wikis and it didn't work too.

    I need to use the GPS coordinates indoor most of the time.

    I have a Nokia C6-01.

    Ovi Maps works fine both outdoors and indoors.

    Here is the header file:
    Code:
    #ifndef GPS_H_
    #define GPS_H_
    
    #include <QGeoPositionInfo>
    #include <QGeoPositionInfoSource>
    
    QTM_USE_NAMESPACE
    
    class GPS : QObject
    {
    Q_OBJECT
    
    public:
      GPS();
      ~GPS();
    
    public slots:
      void
      positionUpdated(const QGeoPositionInfo &info);
      
      void
      updateTimeout();
    
    private:
      QGeoPositionInfoSource *mvp_source;
      QGeoCoordinate mv_coordinate;
    };
    
    #endif /* GPS_H_ */
    Here is the source:
    Code:
    #include "GPS.h"
    
    GPS::GPS()
    {
      this->mvp_source = QGeoPositionInfoSource::createDefaultSource(this);
      this->mvp_source->setPreferredPositioningMethods(QGeoPositionInfoSource::NonSatellitePositioningMethods);
    
      connect(this->mvp_source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
      connect(this->mvp_source, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
    
      this->mvp_source->requestUpdate();
    }
    
    GPS::~GPS() {}
    
    void GPS::positionUpdated(const QGeoPositionInfo &info)
    {
      if (info.isValid())
          this->mv_coordinate = info.coordinate();
    }
    
    void GPS::updateTimeout()
    {
      switch (this->mvp_source->preferredPositioningMethods())
        {
      case QGeoPositionInfoSource::SatellitePositioningMethods:
        this->mvp_source->setPreferredPositioningMethods(QGeoPositionInfoSource::NonSatellitePositioningMethods);
        break;
    
      case QGeoPositionInfoSource::NonSatellitePositioningMethods:
        this->mvp_source->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
        break;
    
      default:
        this->mvp_source->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
        break;
        }
    
      this->mvp_source->requestUpdate(1000 * 30);
    }
    Here is the project file:
    Code:
    TEMPLATE = app
    TARGET = X
    QT += core \
        gui \
        network
    HEADERS += GPS.h \
        X.h
    SOURCES += GPS.cpp \
        X.rss \
        X_reg.rss \
        main.cpp \
        X.cpp
    FORMS += X.ui
    RESOURCES += Resource.qrc
    CONFIG += mobility \
        systeminfo
    TRANSLATIONS = X.ts
    MOBILITY += location \
        sensors
    symbian: { 
        TARGET.UID3 = 0x00000000
        VERSION = 1.0.0
        ICON = Pixmap/Icon128.svg
        MMP_RULES += DEBUGGABLE_UDEBONLY
        vendorInfo = "%{\"X\"}" \
            ":\"X\""
        myDeployment.pkg_prerules += vendorInfo
        TARGET.CAPABILITY = Location \
            NetworkServices \
            ReadUserData \
            WriteUserData \
            ReadDeviceData \
            WriteDeviceData
        autoStartBlock = "SOURCEPATH ." \
            "START RESOURCE X.rss" \
            "END"
        MMP_RULES += autoStartBlock
        deployRscFile = "\"$${EPOCROOT}epoc32/data/X.rsc\" - \"C:/private/X/import/[X].rsc\""
        deployFiles.pkg_postrules += deployRscFile
        pixmapFiles.sources = Pixmap/*
        pixmapFiles.path = .
        DEPLOYMENT += deployFiles
        DEPLOYMENT += pixmapFiles
    }
    I have a valid PublisherID and development certificates.

    The App works fine except for the GPS coordinates part.

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,988

    Re: QGeoPositionInfoSource problem. I tried everything I could.

    Try switching to Network-based GPS from your device settings in the Location application of the device, if its not already On, also try switching to other methods like A-GPS etc.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    29

    Re: QGeoPositionInfoSource problem. I tried everything I could.

    I already tried changing options there in various ways but nothing worked.

    I think the problem isn't there because Ovi Map works fine.

    Note:
    Forgot to tell in my last post that in the emulator positionUpdated is emited but when debugging on device or running the release inside the device it doesn't get emited.

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,988

    Re: QGeoPositionInfoSource problem. I tried everything I could.

    Try with the suggestion given here, though its for N900 , but the scenario is same: http://stackoverflow.com/questions/3...ut-not-on-n900

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    29

    Re: QGeoPositionInfoSource problem. I tried everything I could.

    The suggestion there was to use positionUpdated instead of lastKnownPosition to get the GPS coordinates reading.

    I am already doing that.

    I read that post twice incase there were some clues to try something else I didn't try yet. found nothing usefull.

  6. #6
    Registered User
    Join Date
    Sep 2011
    Posts
    29

    Re: QGeoPositionInfoSource problem. I tried everything I could.

    Being surrounded by tall buildings and no internet (WiFi/3G) available was the cause of my problem.

    Problem is FIXED.

    Thanks for the help.

Similar Threads

  1. QGeoPositionInfoSource initialization problem
    By codestain in forum [Archived] Qt Mobility Project
    Replies: 20
    Last Post: 2011-04-13, 18:31
  2. Issue with QGeoPositionInfoSource
    By davkaplan in forum [Archived] Qt Mobility Project
    Replies: 10
    Last Post: 2010-08-26, 03:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×