Results 1 to 6 of 6

Thread: Find and Send User Current Location like Viber with QT

  1. #1
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Smile Find and Send User Current Location like Viber with QT

    I want to implement an application like viber that can be able to fine user current location and send it on server. I use QT on android.
    here is my code:

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

    QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0);
    if (source){
    qDebug() <<"source->sourceName():" << source->sourceName();
    ui->textEdit->append("sourceName():" + source->sourceName());
    }
    else {
    qDebug() <<"Error:"<< source->error();
    ui->textEdit->append("Error:"+ source->error());
    }
    source->requestUpdate();
    QGeoPositionInfo info = source->lastKnownPosition();
    QGeoCoordinate coordinate = info.coordinate();
    ui->textEdit->append("info.coordinate:"+ coordinate.toString());
    QDateTime timestamp = info.timestamp();
    ui->textEdit->append("info.timestamp():"+ timestamp.toString());
    qDebug() <<"attribute:"<< info.attribute(QGeoPositionInfo::HorizontalAccurac y);

    }

    I finded user current location in "coordinate" variable. now my question is how can i show user current location on a map like viber?
    Last edited by hasti; 23rd September 2014 at 15:47.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Find and Send User Current Location like Viber with QT

    Help with what?
    Wrting the whole applcaiton for you?

    Cheers,
    _

  3. #3
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Default Re: Find and Send User Current Location like Viber with QT

    No,Just tell me where to start. I am studying QT Positioning Classes, but i don't know which classes is useful for me to detect user current location.
    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Find and Send User Current Location like Viber with QT


  5. #5
    Join Date
    Sep 2014
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X Android

    Default Re: Find and Send User Current Location like Viber with QT

    I've changed my codes and I've finded user current location in "coordinate" variable. now my question is how can i detect address from coordinate? I've have user current position coordinate in above code, but i can not find user address based on coordinate and then show country and city. Thanks.

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

    QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0);
    if (source){
    qDebug() <<"source->sourceName():" << source->sourceName();
    ui->textEdit->append("sourceName():" + source->sourceName());
    }
    else {
    qDebug() <<"Error:"<< source->error();
    ui->textEdit->append("Error:"+ source->error());
    }
    source->requestUpdate();
    QGeoPositionInfo info = source->lastKnownPosition();
    QGeoCoordinate coordinate = info.coordinate();
    ui->textEdit->append("info.coordinate:"+ coordinate.toString());
    QDateTime timestamp = info.timestamp();
    ui->textEdit->append("info.timestamp():"+ timestamp.toString());
    qDebug() <<"attribute:"<<info.attribute(QGeoPositionInfo::H orizontalAccurac y);

    QGeoLocation *location = new QGeoLocation();
    location->setCoordinate(coordinate);
    //I want some thing like this: location.setAddress(coordinate);

    QGeoAddress address = location->address();
    qDebug() <<"country:" << address.country();
    qDebug() <<"city:" << address.city();

    }

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Find and Send User Current Location like Viber with QT

    Please explain what you mean by "i can not find user address". What does and what does not work?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Need to find a way to save user inputs.
    By "BumbleBee" in forum Newbie
    Replies: 23
    Last Post: 4th November 2011, 15:10
  2. Replies: 1
    Last Post: 13th June 2011, 14:06
  3. How to find the location of the user?
    By nikhilqt in forum Qt Programming
    Replies: 7
    Last Post: 14th December 2010, 19:22
  4. Send email without user intervention?
    By variance in forum Newbie
    Replies: 1
    Last Post: 10th June 2010, 15:08
  5. Replies: 2
    Last Post: 27th November 2008, 11:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.