Khan
Khan

Reputation: 81

QML-Maps-Qt, tap the screen with a map, processing and obtain the coordinates

I'm making a project with the support of maps on Qt Creator (Community) 5.5.1 for Android. I used QML and now I need some help, because I don't know what I will do further.

First, I determined my location in QML and connected maps. QML-code is here: main.qml:

import QtQuick 2.0
import QtPositioning 5.3
import QtLocation 5.3
Item {
      PositionSource{
          active: true
          onPositionChanged:{
              console.log(position.coordinate);
          }
      }
      Map{
          id: map
          anchors.fill: parent
          plugin: Plugin {name: "osm"}
          center: QtPositioning.coordinate(44.561083, 33.530209)
          zoomLevel: 14
      }
}

And code of main.cpp:

#include <QGuiApplication>
#include <QQuickView>

int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

    QQuickView view;
    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.setResizeMode(QQuickView::SizeRootObjectToView);

    view.resize(300, 400);
    view.show();

    return app.exec();
}

Project is building and running on the Desktop, it's working and maps are showed on the screen. But on the Armeabi (android) they aren't showed. I was testing my programm on the real device. My device DesktopYes, it's running and building, but screen is white and there are some red logs:

E/Zygote (23941): Zygote: error closing descriptor E/Zygote (23941): libcore.io.ErrnoException: close failed: EBADF (Bad file number) E/Zygote (23941): at libcore.io.Posix.close(Native Method) E/Zygote (23941): at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75) E/Zygote (23941): at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:224) E/Zygote (23941): at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879) E/Zygote (23941): at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242) E/Zygote (23941): at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:704) E/Zygote (23941): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) E/Zygote (23941): at dalvik.system.NativeStart.main(Native Method)

E/ (23941): appName=org.qtproject.example.LOCATIONQML, acAppName=/system/bin/surfaceflinger E/ (23941): 0

W/libLOCATIONQML.so(23941): file:///data/data/org.qtproject.example.LOCATIONQML/files/main.qml:-1 ((null)): file:///data/data/org.qtproject.example.LOCATIONQML/files/main.qml: File not found E/ (23941): appName=org.qtproject.example.LOCATIONQML, acAppName=/system/bin/surfaceflinger E/ (23941): 0

W/ResourceType(23941): No package identifier when getting name for resource number 0x00000001

I have two questions:

  1. What I must do for working my programm on real device Android, that maps will be shown on screen of smartphone?
  2. How to do like I tap the screen of smartphone with maps and coordinates of this area are memorized? To further I could compare the user's current location and the location of the point that was clicked on maps screen ?

Upvotes: 2

Views: 426

Answers (1)

Pa_
Pa_

Reputation: 521

Your qml works fine using the latest Qt.

Try to use the standard main() that qt creator generates for you, using QQmlApplicationEngine instead of QQuickView.

Upvotes: 0

Related Questions