美好的一天 !我正在设计一个显示 Map 的 Qt-based GUI platform ,并允许用户在 Map 上添加标记/图钉 .
我使用以下QML在QtQuickWidget中渲染 Map :
Plugin {
id: mapPlugin
name: "osm"
}
我想让用户使用表单上的按钮 add an interactive pin on the map . 用户可以按住 Map 上的一个点,该点将打开表单,用户可以在其中命名该地点并按 OK .
我想要实现的例子:https://webmshare.com/play/5EXV8
-
我尝试过使用QQmlComponent和QQuickView但是我没有成功[http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html]
-
另一种方法是使用MapItems在QML中添加对象,但这非常不直观 . 这是我的map.qml看起来像:https://gist.github.com/blackvitriol/7941688d6362162888630a28c79f8cd9
项目结构:https://imgur.com/a/P8YAS
Can someone tell me how to allow the user to press and hold left click on the map, then add a marker to that point ?
1 回答
一种可能的解决方案是使用
MapItemView
并创建一个存储坐标的模型:markermodel.h
main.qml
main.cpp
完整的示例可以在以下link中找到 .