Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Display GPS Route Data in a Widget
Qt 6.12 LTS is out! See what's new in the release blog

Display GPS Route Data in a Widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    UltraPG
    wrote on last edited by
    #1

    Hello,

    for my research project i made a gui in qt for displaying measurement data and image processing data with opencv. Since we are making the measurement with a moving vehicle, i need to display the driving route on to a map while we a measuring.

    Until now i tried QML Map (Qt Location and openstreetmap) within a QQuickWidget and it worked fine. I can also draw a line with MapPolyline. But i cant interact from my c++ classes to the QML to update the line/route.

    I now have some questions to the experts :)

    • Is my approach going to work? I though if the data handling between c++ and qml through the QQuickWidget does not work, it might be working if i write the data from c++ into a file and read the data in QML. But i have no idea how to read the data and display it the wright way.
    • Are other Methods like ArcGIS, KDE Marble etc better? I've tried those, but could not get them to work.

    Sorry if these are stupid questions but i am a mechanical engineer not a software developper and i am new to the Qt and especially to the QML Game :)

    raven-worxR 1 Reply Last reply
    0
    • U UltraPG

      Hello,

      for my research project i made a gui in qt for displaying measurement data and image processing data with opencv. Since we are making the measurement with a moving vehicle, i need to display the driving route on to a map while we a measuring.

      Until now i tried QML Map (Qt Location and openstreetmap) within a QQuickWidget and it worked fine. I can also draw a line with MapPolyline. But i cant interact from my c++ classes to the QML to update the line/route.

      I now have some questions to the experts :)

      • Is my approach going to work? I though if the data handling between c++ and qml through the QQuickWidget does not work, it might be working if i write the data from c++ into a file and read the data in QML. But i have no idea how to read the data and display it the wright way.
      • Are other Methods like ArcGIS, KDE Marble etc better? I've tried those, but could not get them to work.

      Sorry if these are stupid questions but i am a mechanical engineer not a software developper and i am new to the Qt and especially to the QML Game :)

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @UltraPG said in Display GPS Route Data in a Widget:

      Until now i tried QML Map (Qt Location and openstreetmap) within a QQuickWidget and it worked fine. I can also draw a line with MapPolyline. But i cant interact from my c++ classes to the QML to update the line/route.

      An advice: stay using Qt QML Maps! The mapping of the displayed area to the data in a custom widget can be a very horrific task, even more when you are not a "real" software developer.

      Of course you can interact with the data. Maybe not directly from within C++, but indirectly.
      Means for example: let your C++ code fire some signals and react to them inside your QML code, which then does the appropriate work.

      You may want to start reading here.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @UltraPG you may already have taken a look at this QML Map Viewer, but just in case.

        It looks very promising as it has several features, including directions and travel routes via RouteModel and MapRoute QML types. So it seems that most of the components you might need for your project are already available on QML and you may eventually interact with them from C++ as indicated in previous post.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • U Offline
          U Offline
          UltraPG
          wrote on last edited by
          #4

          Thanks for the help. I've managed it now to interact between C++ and QML. But i can't get to work the invokeMethod to start a function inside QML from C++ with the QQuickWidget.

          From the Link there is this example:

          QML:

          import QtQuick 2.0
          
          Item {
              function myQmlFunction(msg) {
                  console.log("Got message:", msg)
                  return "some return value"
              }
          }
          

          C++:

              QQuickWidget *quickWidget = new QQuickWidget();
              QQmlContext* context = quickWidget->rootContext();
          
              //Method to access properties between QML and C++
              context->setContextProperty("dataStore", &dt);
              quickWidget->setSource(QUrl(QStringLiteral("qrc:/main.qml")));
              quickWidget->show();
              ui->verticalLayout->addWidget(quickWidget);
              
              //Method to call a function from QML in C++
              QObject *obj = context->contextObject();
              QVariant returnedValue;
              QVariant msg = "Hello from C++";
              QMetaObject::invokeMethod(obj,"myQmlFunction",Q_RETURN_ARG(QVariant, returnedValue),Q_ARG(QVariant, msg));
          
              qDebug() << "QML function returned: " << returnedValue.toString();
          

          But the function inside QML won't be excecuted. How is the correct way to call a QML function from a QQuickWidget inside C++?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved