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

QGeoPositionInfoSource does not work from C++ code with QCoreApplication

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.1
    • 5.11.2
    • Positioning
    • None
    • * Qt 5.11.2 MSVC2015 32 bit
      * Windows 10 64 bit
    • Windows
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            owolff Oliver Wolff
            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