【问题标题】:How to get location using qml - BlackBerry如何使用 qml 获取位置 - 黑莓
【发布时间】:2013-06-07 21:23:45
【问题描述】:

是否可以仅使用 qml 在 BlackBerry 中获取经度和纬度?我找到了http://dengineer.com/adding-qml-gps-to-blackberry-10/,但它不起作用。我的设备上只有黑屏。 这是我的代码:

import bb.cascades 1.0
import QtMobilitySubset.location 1.1
Page {
    property string longitude
    property string latitude
    property variant cord
    Container {
        layout: DockLayout {}
        attachedObjects: [
            PositionSource{
                id: location
                updateInterval: 1000

                onPointChanged: {
                    cord = location.position.coordinate;
                    longitude = cord.longitude;
                    latitude = cord.latitude;
                    result.setText(longitude + " " + latitude)
                }

            }]
        Button {
            text: qsTr("Locate me")
            horizontalAlignment: HorizontalAlignment.Center
            onClicked: { 
                location.start()
            }
        }
        Label {
            id: result
            text: qsTr("0 0")
            textStyle.base: SystemDefaults.TextStyles.BigText
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
}

我有错误: Jun 08 19:31:14.025 com.example.GPS_qml.testDev_ple_GPS_qml341af9aa.30007492 默认 9000 警告 --- 错误:(file:///apps/com.example.GPS_qml.testDev_ple_GPS_qml341af9aa/native/assets//main.qml:32 :13: 无法分配给不存在的属性“onPointChanged” onPointChanged:{ ^)

【问题讨论】:

    标签: blackberry location qml


    【解决方案1】:

    我对 QML 的理解是它仅用于显示,您必须编写一些本机代码来完成您需要的操作。见样本

    https://github.com/blackberry/Cascades-Samples

    您可以检查 locationdiagnostics 项目,给出 Location API 的示例

    【讨论】:

    • 我发现了这样的东西:dengineer.com/adding-qml-gps-to-blackberry-10 但它不起作用。在构建期间我有C:\bbndk\host_10_1_0_132\win32\x86\usr\bin\ntox86-ld: cannot find -lQtLocation make[2]: Leaving directory C:/Users/Krzysztof/ndk-10.1.0-workspace/GeoLocation_qml/x86' cc: C:/bbndk/host_10_1_0_132/win32/x86/usr/bin/ntox86-ld caught signal 1 make[1]: Leaving directory C:/Users/Krzysztof/ndk-10.1.0-workspace/GeoLocation_qml/x86' make[2]: *** [o-g/GeoLocation_qml] Error 1 make[1]: *** [debug] Error 2 make: *** [Simulator-Debug] Error 2
    • 此错误是在将 MOBILITY += location 添加到我的 .pro 文件之后发生的。
    • 我相信你和这个链接208.74.204.192/t5/Cascades-Development/…有同样的问题,检查一下,解决方案使用 MOBILITY -= location (- 而不是 +)
    • 感谢您的回复。构建过程中没有错误,但运行后仍然黑屏。我找不到任何错误。
    • 您正在检查设备日志对吗?我建议您删除一些 qml 部分并逐个添加直到遇到问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多