Place pickers

A PlacePicker allows you to browse and select places. The PlacePicker supports choosing places based on the current location of a user, from a database of favorites, from recent selections, from contact addresses, and from remote search results.

The PlacePicker class extends the CustomControl class, and consists of a set of sheets running modally. When a PlacePicker is in focus, operations are blocked until you select a place or cancel the PlacePicker.

A PlacePicker returns a SelectedPlace object pointer when a selection is made. A non-null pointer indicates that a place has been selected successfully.

You must enable the location capability in your app to launch some features of a PlacePicker, such as 'My Location' and local point-of-interest search.

Screen showing a place picker control.


To use the PlacePicker class, you must link to the Places library:

If you are using an API level of 10.1 or later, you don't need to register the PlacePicker and SelectedPlace custom controls. You just have to import the bb.cascades.places library in your QML file.

If you are using API level 10.0, to use the PlacePicker and SelectedPlace classes in QML, you must register the PlacePicker and SelectedPlace custom controls.

import bb.cascades.places 1.0

Add the following code to your main.cpp file:

#include <bb/cascades/places/PlacePicker>
#include <bb/cascades/places/SelectedPlace>

    ("bb.cascades.places", 1, 0, "PlacePicker");
    ("bb.cascades.places", 1, 0, "SelectedPlace", "");

Not applicable

Not applicable

To use some functionality of PlacePicker, your app must have the Location permission.

Creating a place picker

Here's a code sample that shows you how to create a PlacePicker. The PlacePicker is attached to a Button that displays the PlacePicker and updates the Label text according to the selected place.

import bb.cascades.places 1.0
Page {
  Container {
    Label {
      id: title
      text: "Place name selected"
    Button {
      text: "Click to open PlacePicker"
      onClicked: {
        var place = ()
        if (place) {
          title.text =
        else {
          title.text = "No place selected"
  attachedObjects: [
    PlacePicker {
      id: picker

Using a QScopedPointer, the sample code creates a PlacePicker and call its show() function. The sample code also creates a SelectedPlace that used to work with the value returned by the show() function. The show() function returns a pointer to the place selected, if it's successful, and a null pointer otherwise.

#include <bb/cascades/places/PlacePicker>
#include <bb/cascades/places/SelectedPlace>
#include <QScopedPointer>
QScopedPointer<PlacePicker> picker = new PlacePicker();
SelectedPlace *sp = picker->show();

if (sp != NULL) {
  // Extract details from SelectedPlace object
  // Detaches sp from parent picker so it can 
  // still be used after the picker is destroyed
else {
  // The operation is canceled by the user, or 
  // location capability is not enabled
// Destruction of the picker pointer is handled by QScopedPointer

Not applicable

For a more detailed PlacePicker code sample, see the PlacePicker sample in GitHub.

Last modified: 2015-07-24

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus