Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Best way to draw gps point with qt



  • I dont really know how to ask this question but I will do my best to explain. I have a project on arduino with a gps, I transfere the geo point via serialdata on my pc. I can read it without probleme, but where I need help is how I can draw a path of that point. for the moment I use this:

    void MainWindow::paintEvent(QPaintEvent* p)
    {
        QPainter painter(this); //class must be implemented from QWidget
        painter.setPen(pen);
        painter.setRenderHint(QPainter::Antialiasing);
        painter.setRenderHint(QPainter::HighQualityAntialiasing);
        painter.translate(width() / 2-466133, height() / 2+727150);
        painter.scale(10000.0,10000.0);
    
        painter.drawPolyline(polyPoints);
    }
    
    void MainWindow::readData(QStringList data)
    {
        ui->textEdit->setText(data.join(","));
        polyPoints  << QPointF(data[0].toDouble(),data[1].toDouble());
        QWidget::update();
    }
    

    my point is something like that:

    46.612823, -72.702957
    46.612876, -72.702873
    46.612937, -72.702789

    like you see the difference between 2 point are very very small so I need to scalle this way up and a need to work with rediculous number for translate my origin. for the moment the translate is fixe but in the futur it will be dynamic.

    there an image to show more what I need at the end

    630593f0-0ca8-4b45-a97f-2379139fb4ae-image.png

    I hope that you understand my problem.

    thank you



  • @Bestrider14

    Take all your data points you have in one set and normalize them to a range that matches your scale.


  • Qt Champions 2019

    Or take a proper widget which handles this all for you like ESRI ArcGIS runtime for Qt



  • @Christian-Ehrlicher Ho thanks I will try this widget. It look like is what I need at firt sight.


Log in to reply