×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Post How to get the Latitude and Longitude of the mobile in QT ??

    Hi All,
    I am new to Qt i am in need of getting the latitude and longitude of the mobile.
    I had searched this below website but i am unable to get the desired result!!

    http://www.developer.nokia.com/Commu...location_in_Qt

    I tried it by editing and also downloaded the zip file and run but i could not find the any solution.

    If anyone comes up with an answer will be highly appreciated!!!!!

    Thanks in advance and Regards,
    Naufal.A

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    What do you get in result?

    Note that GPS receiver may receive poor data in closed environment(Or in weather with dense cloud). You will get better data in open space (outside office or terrace).

  3. #3
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    What device are you using ? What are the errors ? How you are using the code ?

    regards,
    rahul

  4. #4
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Quote Originally Posted by rahulvala View Post
    What device are you using ? What are the errors ? How you are using the code ?
    Hi Rahulvala,
    I am using C7 nokia phone,before that i have a doubt, that i did not try it installing in mobile phone, i tried only in simulator.
    Whether it would work properly??? or else i have to install and check it out??

    I did not get any error , i am getting a white screen with a dialog box displaying the no. of satellite monitors!!!

    Thanks in advance and Regards,
    Naufal.A
    Last edited by naufalahad; 2011-11-15 at 08:48. Reason: mistake

  5. #5
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Quote Originally Posted by savaj View Post
    What do you get in result?

    Note that GPS receiver may receive poor data in closed environment(Or in weather with dense cloud). You will get better data in open space (outside office or terrace).
    Hi Savaj,
    I am using c7 mobile but i did not install and checked it out ... i tried only in Qt software
    Here is the main.cpp code in which i get an error stating geoPositionInfo was not decalred and i cannot call the function from main.cpp to mainwindow.cpp

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    MainWindow mainWindow;
    mainWindow.startGPS();
    mainWindow.positionUpdated(geoPositionInfo);

    // mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
    mainWindow.showExpanded();
    return app.exec();
    }


    Thanks in advance and Regards,
    Naufal.A
    Last edited by naufalahad; 2011-11-15 at 08:53. Reason: mistake

  6. #6
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Ya, sure ,It should work ,and that code was checked and run in the device.

    Try to check in your device,

  7. #7
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi Rahulvala,
    I will check out and let you know in sometime!!!

    Thanks a lot and Regards,
    Naufal.A

  8. #8
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Quote Originally Posted by rahulvala View Post
    Ya, sure ,It should work ,and that code was checked and run in the device.

    Try to check in your device,
    Hi Rahulvala,
    I am getting errors while building and creating a sis file.
    I am not able find out those errors and also sis file is not created!!!!

    These are the errors which i get when i give build:
    F:\rarfiles\QtMobilityLocation\LocationAPIExample\src\mainwindow.cpp:1: In file included from F:/rarfiles/QtMobilityLocation/LocationAPIExample/src/mainwindow.cpp:1:
    F:\rarfiles\QtMobilityLocation\LocationAPIExample\src\mainwindow.h:4: error: QtCore/QPointer: No such file or directory
    :-1: error: Recipe compile failed with exit code 1.
    :-1: Running command: C:/QtSDK/Symbian/tools/gcce4/bin/arm-none-symbianelf-g++.exe -O0 -g -gdwarf-2 -fexceptions -Wall -Wno-unknown-pragmas -march=armv5te -mapcs -mthumb-interwork -c -mthumb -D__MARM_THUMB__ -mfloat-abi=soft -fvisibility-inlines-hidden -x c++ -Wno-ctor-dtor-privacy -D__MARM_INTERWORK__ -D__SUPPORT_CPP_EXCEPTIONS__ -D_UNICODE -D__SYMBIAN32__ -D__EPOC32__ -D__MARM__ -D__EABI__ '-D__PRODUCT_INCLUDE__="C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/feature_settings.hrh"' -DUNICODE -DQT_KEYPAD_NAVIGATION -DQT_SOFTKEYS_ENABLED -DQT_USE_MATH_H_FLOATS -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D__MARM_ARMV5__ -D__GCCE_4__ -D__GCCE_4_4__ -D_DEBUG -D__GCCE__ -D__EXE__ -D__SYMBIAN_STDCPP_SUPPORT__ -include C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/gcce/gcce.h -IF:/rarfiles/QtMobilityLocation/LocationAPIExample/src -IF:/rarfiles/QtMobilityLocation/LocationAPIExample -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include/QtCore -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include/QtGui -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include/QtWebKit -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/mkspecs/common/symbian -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/stdapis -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/stdapis/sys -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/mw -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform/mw -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform/loc -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform/mw/loc -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform/loc/sc -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/platform/mw/loc/sc -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/stdapis/stlportv5 -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include/QtXmlPatterns -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/include/QtNetwork -IF:/rarfiles/QtMobilityLocation/LocationAPIExample/moc -IF:/rarfiles/QtMobilityLocation/LocationAPIExample/src -IF:/rarfiles/QtMobilityLocation/LocationAPIExample/ui -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include -IC:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/include/stdapis -MD -MF C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/build/locationapiexample/c_542cab462d0bec16/LocationAPIExample_exe/armv5/udeb/mainwindow.o.d -o C:/QtSDK/Symbian/SDKs/SymbianSR1Qt474/epoc32/build/locationapiexample/c_542cab462d0bec16/LocationAPIExample_exe/armv5/udeb/mainwindow.o F:/rarfiles/QtMobilityLocation/LocationAPIExample/src/mainwindow.cpp
    In file included from F:/rarfiles/QtMobilityLocation/LocationAPIExample/src/mainwindow.cpp:1:
    F:/rarfiles/QtMobilityLocation/LocationAPIExample/src/mainwindow.h:4: fatal error: QtCore/QPointer: No such file or directory
    compilation terminated.
    F:\rarfiles\QtMobilityLocation\LocationAPIExample\src\main.cpp:1: In file included from F:/rarfiles/QtMobilityLocation/LocationAPIExample/src/main.cpp:1:
    F:\rarfiles\QtMobilityLocation\LocationAPIExample\src\mainwindow.h:4: error: QtCore/QPointer: No such file or directory
    :-1: error: Recipe compile failed with exit code 1.
    F:\rarfiles\QtMobilityLocation\LocationAPIExample\moc\..\src\mainwindow.h:4: error: QtCore/QPointer: No such file or directory
    :-1: error: Recipe compile failed with exit code 1.
    :-1: error: The make-engine exited with errors.

    Thanks and Regards,
    Naufal.A

  9. #9
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    your project and source of Qt SDK , both are in different directory, create project in the directory where Qt SDK is installed.

    then check again.

    regards,
    rahul

  10. #10
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi Rahulvala,
    Ya i got the sis file when storing the file in the same directory and i will check for the result!!!!!
    Thanks a lotttt

    Thanks and Regards,
    Naufal.A
    Last edited by naufalahad; 2011-11-15 at 11:25.

  11. #11
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi Rahulvala,
    Can i know what will be the output???
    i am getting a blank screen and nothing else in that page!!!!
    if you know the resultant output kindly tell me ..

    Thanks and Regards,
    Naufal.A

  12. #12
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Question Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi,
    I had tried using the below link and i am unable to retrieve any values from that ..

    http://www.developer.nokia.com/Commu...location_in_Qt

    Can i know how to get the latitude and longitude values that should be displayed in ie, messagebox or something else!

    Kindly anyone help me in getting me a solution for it.

    Thanks in advance and Regards,
    Naufal.A

  13. #13
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi,
    This is my .h and .cpp files.
    May i know what is the error and problem in this???
    Can anyone solve these

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:
    enum ScreenOrientation {
    ScreenOrientationLockPortrait,
    ScreenOrientationLockLandscape,
    ScreenOrientationAuto
    };

    explicit MainWindow(QWidget *parent = 0);
    virtual ~MainWindow();

    // Note that this will only have an effect on Symbian and Fremantle.
    void setOrientation(ScreenOrientation orientation);

    void showExpanded();

    private slots:
    void on_pushButton_clicked();

    private:
    Ui::MainWindow *ui;
    };

    #endif // MAINWINDOW_H


    QGeoPositionInfo.h


    #include <QGeoPositionInfo>
    #include <QGeoPositionInfoSource>


    #include <QDebug>

    #include <QPointer>

    // QtMobility namespace
    QTM_USE_NAMESPACE

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public slots:
    /**
    * Called when the current position is updated.
    */
    void positionUpdated(QGeoPositionInfo geoPositionInfo);

    public:
    /**
    * Obtains the location data source and starts listening for position
    * changes.
    */
    void startGPS();

    private:
    QPointer<QGeoPositionInfoSource> locationDataSource;
    QGeoPositionInfo myPositionInfo;
    }

    main.cpp


    #include "mainwindow.h"

    #include <QtGui/QApplication>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    MainWindow mainWindow;
    mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
    mainWindow.showExpanded();

    return app.exec();
    }

    mainwindow.cpp


    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "qgeopositioninfo.h"

    #include <QtCore/QCoreApplication>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::setOrientation(ScreenOrientation orientation)
    {
    #if defined(Q_OS_SYMBIAN)
    // If the version of Qt on the device is < 4.7.2, that attribute won't work
    if (orientation != ScreenOrientationAuto) {
    const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
    if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
    qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
    return;
    }
    }
    #endif // Q_OS_SYMBIAN

    Qt::WidgetAttribute attribute;
    switch (orientation) {
    #if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    case ScreenOrientationLockPortrait:
    attribute = static_cast<Qt::WidgetAttribute>(128);
    break;
    case ScreenOrientationLockLandscape:
    attribute = static_cast<Qt::WidgetAttribute>(129);
    break;
    default:
    case ScreenOrientationAuto:
    attribute = static_cast<Qt::WidgetAttribute>(130);
    break;
    #else // QT_VERSION < 0x040702
    case ScreenOrientationLockPortrait:
    attribute = Qt::WA_LockPortraitOrientation;
    break;
    case ScreenOrientationLockLandscape:
    attribute = Qt::WA_LockLandscapeOrientation;
    break;
    default:
    case ScreenOrientationAuto:
    attribute = Qt::WA_AutoOrientation;
    break;
    #endif // QT_VERSION < 0x040702
    };
    setAttribute(attribute, true);
    }

    void MainWindow::showExpanded()
    {
    #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    showFullScreen();
    #elif defined(Q_WS_MAEMO_5)
    showMaximized();
    #else
    show();
    #endif
    }

    void MainWindow:n_pushButton_clicked()
    {
    QGeoPositionInfo *ge = new QGeoPositionInfo;
    ge->startGPS();
    }

    QGeoPositionInfo.cpp


    #include "qgeopositioninfo.h"
    #include "ui_qgeopositioninfo.h"
    #include <QGeoCoordinate>

    QGeoPositionInfo::QGeoPositionInfo(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QGeoPositionInfo)
    {
    ui->setupUi(this);
    }

    QGeoPositionInfo::~QGeoPositionInfo()
    {
    delete ui;
    }



    void QGeoPositionInfo::startGPS()
    {
    // Obtain the location data source if it is not obtained already
    if (!locationDataSource)
    {
    locationDataSource =
    QGeoPositionInfoSource::createDefaultSource(this);
    // Whenever the location data source signals that the current
    // position is updated, the positionUpdated function is called
    connect(locationDataSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
    this, SLOT(positionUpdated(QGeoPositionInfo)));

    // Start listening for position updates
    locationDataSource->startUpdates();
    }
    }

    void QGeoPositionInfo:ositionUpdated(QGeoPositionInfo geoPositionInfo)
    {
    if (geoPositionInfo.isValid())
    {
    // We've got the position. No need to continue the listening.
    locationDataSource->stopUpdates();

    // Save the position information into a member variable
    myPositionInfo = geoPositionInfo;

    // Get the current location as latitude and longitude
    QGeoCoordinate geoCoordinate = geoPositionInfo.coordinate();
    qreal latitude = geoCoordinate.latitude();
    qreal longitude = geoCoordinate.longitude();
    qDebug() << QString("Latitude: %1 Longitude: %2").arg(latitude).arg(longitude);
    }
    }

  14. #14
    Regular Contributor
    Join Date
    Nov 2011
    Location
    Coimbatore
    Posts
    87

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi,
    As already stated, i am getting only blank screen while running on both simulator and also in mobile phone.
    I had tried implementing in a new application and also different methods but i am unable to get the result than blank screen.

    This is the link below where i have downloaded the .zip file and tried running the application.

    http://www.developer.nokia.com/docum...cation/05.html

    I need some help on what to do and how to get the latitude and longitude of the current location.
    The UI is also empty and i cannot able to find out or create any message box to display it.

    Can anyone come up with an solution will be very much appreciated!!!

    Thanks in advance and regards,
    Naufal.A

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: How to get the Latitude and Longitude of the mobile in QT ??

    Hi,
    I just copied the following code from the map demo example (part of mobility example) It should work.
    It will gives you the latitude and longiture that you can show in notes or dialog what ever..

    QGeoPositionInfoSource * positionSource = QGeoPositionInfoSource::createDefaultSource(this);

    if (!positionSource) {
    // some...
    } else {
    positionSource->setUpdateInterval(1000);
    connect(positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
    this, SLOT(updateMyPosition(QGeoPositionInfo)));
    positionSource->startUpdates();
    }
    }




    void MainWindow::updateMyPosition(QGeoPositionInfo info)
    {
    qDebug() << " MainWindow::updateMyPosition" ;
    if (info.isValid()) {
    QGeoCoordinate coord = info.coordinate();
    double latitude = coord.latitude();
    double longitude = coord.longitude();

    qDebug() << latitude;
    qDebug() << longitude;
    }
    }
    Last edited by mahbub_s60; 2011-11-16 at 06:53.

Similar Threads

  1. How to get longitude latitude value of any GPS enabled mobile?
    By versha_vinay2006 in forum [Closed] Publishing to Nokia Store
    Replies: 1
    Last Post: 2011-04-09, 15:00
  2. set latitude and Longitude
    By sridharbandi in forum Symbian
    Replies: 4
    Last Post: 2010-12-27, 06:35
  3. getting latitude and longitude
    By arun09 in forum Symbian
    Replies: 1
    Last Post: 2009-06-13, 13:39
  4. Latitude/Longitude on map
    By piterr1410 in forum Mobile Java General
    Replies: 10
    Last Post: 2008-07-08, 16:55

Posting Permissions

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