Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
lietorob
Posts: 8
Registered: ‎07-23-2012
My Device: Bold 9930, Dev Alpha, PlayBook 32 gb
My Carrier: Verizon
Accepted Solution

trying to use Qt Mobility 1.2 - how to add correct library?

Using the QML PositionSource that is a part of Qt Mobility 1.2 but keep getting an "module "QtMobility.location" is not installed" . At the top of my main.qml page i have "import QtMobility.location 1.2" but not sure what else i need to do at this point. 

 

Any ideas? I'm a total rook at developing so the more info the better..

Please use plain text.
Developer
oniongarlic
Posts: 72
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB
My Carrier: Sonera, Saunalahti

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Use import QtMobilitySubset.location 1.1 The BB10 Qt Mobility does not contain the full implementation unfortunately.
Please use plain text.
New Contributor
lietorob
Posts: 8
Registered: ‎07-23-2012
My Device: Bold 9930, Dev Alpha, PlayBook 32 gb
My Carrier: Verizon

Re: trying to use Qt Mobility 1.2 - how to add correct library?

that worked! however, is there anything else i need to do to initialize the gps? 

 

is positionSource.start() within the onButtonClicked {} the correct way? i'm attempting to start the gps and on an interval update the position then use the coordinate.distanceTo() function to calculate distance traveled. 

Please use plain text.
Developer
oniongarlic
Posts: 72
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB
My Carrier: Sonera, Saunalahti

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Yes, you can use .start() and .stop() or just .active=true/false

Afaik, distanceTo() is one those methods that is not available in the subset provided.

But there are plenty of examples on the how to do that. Just search for "Great circle distance" and you should find it.
Please use plain text.
New Contributor
jvaldezp
Posts: 8
Registered: ‎02-26-2013
My Device: alpha 10 dev
My Carrier: nothing... device for developer

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Hi, I have the same problem, but my view indicates QML, Unknown library 'QtMobilitySubset.location' and add to the library archivo.pro  LIBS + =-lQtLocationSubset, similarly granted permission as at the bar descriptor (Location), not really know what to do, I'm working with the beta version 1.10
Please use plain text.
BlackBerry Development Advisor
jehrismann
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Hi,

 

The QML PositionSource, Position, and Coordinate elements are supported, including the Coordinate's distanceTo() method.

 

Jim

Please use plain text.
BlackBerry Development Advisor
jehrismann
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Hi,

 

jvaldezp, do you mean beta NDK 10.1? The QtMobilitySubset.location qml plugin should be available. Note that you don't need to add LIBS + =-lQtLocationSubset to your .pro file if you are just using the QML location elements. But you do need the access_location_services permission in the bar descriptor file.

 

Jim

Please use plain text.
New Contributor
jvaldezp
Posts: 8
Registered: ‎02-26-2013
My Device: alpha 10 dev
My Carrier: nothing... device for developer

Re: trying to use Qt Mobility 1.2 - how to add correct library?

certainly is what I read in the documentation, but when running the application it does nothing, the screen stays black., try running the following code I found on the forum, I additionally QtMobilitySubset.location indicates that the module is not installed or unknown library QtMobilitySubset.location.

  • // Navigation pane project template
  • import bb.cascades 1.0
  • import QtMobilitySubset.location 1.1
  •  
  • NavigationPane {
  •     id: navigationPane
  •  
  •     //! GPS Variables
  •     property string latitude
  •     property string longitude
  •     property variant currentCoord
  •  
  •     Page {
  •         // page with a picture thumbnail
  •         Container {
  •             background: Color.Black
  •             layout: DockLayout {
  •             }
  •             Button {
  •                 horizontalAlignment: HorizontalAlignment.Center
  •                 verticalAlignment: VerticalAlignment.Center
  •                 text: qsTr("Show detail")
  •                 imageSource: "asset:///images/picture1thumb.png"
  •                 onClicked: {
  •                     positionSource.start()
  •  
  •                     // show detail page when the button is clicked
  •                     var page = getSecondPage();
  •                     console.debug("pushing detail " + page)
  •                     navigationPane.push(page);
  •                 }
  •                 property Page secondPage
  •                 function getSecondPage() {
  •                     if (! secondPage) {
  • secondPage = secondPageDefinition.createObject();
  •                     }
  •                     return secondPage;
  •                 }
  •                 attachedObjects: [
  •                     ComponentDefinition {
  •                         id: secondPageDefinition
  •                         source: "DetailsPage.qml"
  •                     }
  •                 ]
  •             }
  •         }
  •     }
  •     onCreationCompleted: {
  •         // this slot is called when declarative scene is created
  •         // write post creation initialization here
  •         console.log("NavigationPane - onCreationCompleted()");
  •  
  •         // enable layout to adapt to the device rotation
  •         // don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
  •         OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
  •     }
  •  
  •  
  •     attachedObjects: [PositionSource {
  •     id: positionSource//! Desired interval between updates in milliseconds
  •     updateInterval: 10000//! When position changed, update the location strings
  •     onPositionChanged: {
  •     currentCoord = positionSource.position.coordinate;
  •     latitude = currentCoord.latitude;
  •     longitude = currentCoord.longitude;
  •     console.debug(latitude, longitude);
  •     positionSource.stop();}
  •     }
  •     ]
  • }

 

Please use plain text.
BlackBerry Development Advisor
jehrismann
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Hi,

 

I tried that qml without luck, even with some reworking. There may be other issues with it. Here's is a sample that works for me:

/* Copyright (c) 2012 Research In Motion Limited.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Importing all our cascades functions.
import bb.cascades 1.0
import QtMobilitySubset.location 1.1

Page {
    id: mainPage

    // A container is used to gather visual items together.
    Container {
        // A DockLayout is applied to the main container, this makes it
        // possible to layout controls and view inside the container.
        layout: DockLayout {
        }

        attachedObjects: [
            TextStyleDefinition {
                id: tsd
                base: SystemDefaults.TextStyles.BodyText
                fontSize: FontSize.XSmall
            },

            PositionSource {
                id: positionSource
                updateInterval: 1000
                active: true
            },

            Coordinate {
                id: startCoord
                latitude: 44.48197262
                longitude: -80.2411541
                altitude: 340
            }
        ]

        // The container containing the bubble image and text.
        Container {
            id: positionInfo
            layout: StackLayout {
            }

            Label {
                text: "<==== PositionSource ====>"
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "positioningMethod: " + positionInfo.printableMethod(positionSource.positioningMethod)
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "nmeaSource: " + positionSource.nmeaSource
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "updateInterval: " + positionSource.updateInterval
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "active: " + positionSource.active
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "<==== Position ====>"
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: "timestamp: " + positionSource.position.timestamp
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.latitudeValid ? positionSource.position.coordinate.latitude : "--"
                    return "latitude: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.longitudeValid ? positionSource.position.coordinate.longitude : "--"
                    return "longitude: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.horizontalAccuracyValid ? positionSource.position.horizontalAccuracy : "--"
                    return "horizontal accuracy: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.altitudeValid ? positionSource.position.coordinate.altitude : "--"
                    return "altitude: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.verticalAccuracyValid ? positionSource.position.verticalAccuracy : "--"
                    return "vertical accuracy: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = positionSource.position.speedValid ? positionSource.position.speed : "--"
                    return "speed: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }
            Label {
                text: {
                    var outStr = (positionSource.position.latitudeValid && positionSource.position.longitudeValid ) ? positionSource.position.coordinate.distanceTo(startCoord) : "--"
                    return "distance to start: " + outStr
                }
                textStyle {
                    base: tsd.style
                }
            }

            function printableMethod(method) {
                if (method == PositionSource.SatellitePositioningMethod) return "Satellite";
                else if (method == PositionSource.NoPositioningMethod) return "Not available";
                else if (method == PositionSource.NonSatellitePositioningMethod) return "Non-satellite";
                else if (method == PositionSource.AllPositioningMethods) return "All/multiple"
                return "source error";
            }
        }
    }
}

You can get this to work with a project based on the default empty project template in the Momentix IDE (File -> New -> Project... -> BlackBerry Project -> Cascades Application -> Standard empty project) simply by replacing the content of the project's main.qml file with the code above. Also, you must add location permission to the bar-descriptor.xml file:

    <permission>access_location_services</permission>

 And make sure Location Services is enabled on device (Settings -> Location Services)

 

Hope this helps,

Jim

 

Please use plain text.
New Contributor
jvaldezp
Posts: 8
Registered: ‎02-26-2013
My Device: alpha 10 dev
My Carrier: nothing... device for developer

Re: trying to use Qt Mobility 1.2 - how to add correct library?

Hi Jim, thanks again., I do not know what happens ... create a new project, copy your code, in addition to the bar descriptor.xml have permission ... but not run, this is my version of the QNX ® Momentics ® IDE for BlackBerry ® 10 Native SDK Version: 10.1.0, I was reading and says that this plugin is not available for qml ...

Please use plain text.