Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-71194

QGeoPositionInfoSource does not work from C++ code with QCoreApplication

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.11.2
    • Fix Version/s: 5.12.1
    • Component/s: Positioning
    • Labels:
      None
    • Environment:
      * Qt 5.11.2 MSVC2015 32 bit
      * Windows 10 64 bit
    • Platform/s:
      Windows
    • Commits:
      10e200d710254a30dc5e2d4eb2104f3f2b7f7f0c (qt/qtlocation/5.12)

      Description

      Attempt to use the QGeoPositionInfoSource from a pure C++ code:

      == main.cpp ==

      #include <QCoreApplication>
      #include <QGeoPositionInfoSource>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          const auto src = QGeoPositionInfoSource::createDefaultSource(qApp);
      
          return a.exec();
      }
      
      

      == *.pro ==

      ...
      QT -= gui
      QT += positioning
      ...
      

      fails with this message:

      Could not initialize native location services. (Не был произведен вызов CoInitialize.)
      Could not register status changed callback (Не был произведен вызов CoInitialize.)

      But it works with QML's PositionSource item.

       ===

       A workaround is to use Qt += widgets and use QApplication instead of QCoreApplication

        Attachments

        For Gerrit Dashboard: QTBUG-71194
        # Subject Branch Project Status CR V

          Activity

            People

            • Assignee:
              owolff Oliver Wolff
              Reporter:
              kuzulis Denis Shienkov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes