×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    1

    Problem getting network-based location

    Hi guys,

    I'm trying to write an application that gets the location of the phone using the 'Network based' positioning method.

    Unfortunately, setting the preferred positioning method to 'NonSatellitePositioningMethods' doesn't seem to have any effect, even though calls to supportedPositioningMethods() return the 'AllPositioningMethods' flag.

    I'm running my program on a Nokia N95 with Qt Mobility 1.0.0 installed, indoors (therefore no GPS reception) but with good network reception.

    If I edit the positioning methods in the phone's settings app so that only 'Network based' is available, the following code returns a network-based location.

    However, if I enable 'Assisted GPS' in the phone's settings, my preferred positioning method setting is ignored, the phone attempts to use GPS, and the position request times out.

    Is this a bug, or am I just doing it wrong?

    Code:
    Positioning::Positioning(QObject *parent)
        : QObject(parent)
    {
        QGeoPositionInfoSource *positionManager = QGeoPositionInfoSource::createDefaultSource(this);
        positionManager->setPreferredPositioningMethods(QGeoPositionInfoSource::NonSatellitePositioningMethods);
    
        connect(
                positionManager, SIGNAL(positionUpdated(QGeoPositionInfo)),
                this, SLOT(positionUpdated(QGeoPositionInfo))
                );
        connect(
                positionManager, SIGNAL(updateTimeout()),
                this, SLOT(updateTimeout())
                );
    
        positionManager->requestUpdate(30000); // time out after 30 seconds
    }
    
    void Positioning::positionUpdated(QGeoPositionInfo position)
    {
        qDebug() << "Position request succeeded.";
    }
    
    void Positioning::updateTimeout()
    {
        qDebug() << "Position request timed out.";
    }
    Last edited by campbeltonian; 2010-05-04 at 15:18. Reason: Forgot to mention return value of supportedPositioningMethods()

Similar Threads

  1. 编译Qt样例出错,请看如下
    By TD3 in forum [Archived] Qt General ( Qt技术)
    Replies: 14
    Last Post: 2009-12-24, 03:23
  2. Network based location in Python?
    By miohtama in forum Symbian
    Replies: 4
    Last Post: 2007-12-31, 09:40

Posting Permissions

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