ContactPicker

Anyone successfully use the ContactPicker?

I have this error on compiling:

reference to the undefined ' bb::cascades:ickers::ContactPicker:ContactPicker(QObject*)'

When I write this:

ContactPicker * contactPicker = new ContactPicker();

Without forgotting include:

  • include: #include
  • space of names: using namespace bb::cascades:ickers.
  • int file pri LIBS: LIBS +=-lbbpim

I don't see any use of the ContactPicker in the sample of any github and don't understand why it doesn't work.

Help!

Hello! Add LIBS +=-lbbcascadespickers

Tags: BlackBerry Developers

Similar Questions

  • HELP the multiple ContactPicker in QML

    I have this code

    ActionItem
                {
                    title: "Invite Contacts"
                    ActionBar.placement: ActionBarPlacement.OnBar
                    imageSource: "asset:///images/titleAddFriend.png"
                    onTriggered:
                    {
                        contactPicker.open();
                    }
    
                    attachedObjects: ContactPicker
                    {
                        id: contactPicker
                        mode: ContactSelectionMode.Multiple
                        onContactsSelected:
                        {
                            for(var i = 0; i < selectedContactsIds.length; i++)
                            {
                                var phoneNumber = _app.getContactPhoneNumber(selectedContactsIds[i]);
                                console.log("PHONE: " + phoneNumber);
                            }
                        }
                    }
                }
    

    but does simply not multiple selector. It still operates as the single contact selector by default. I added a qml register type in main.cpp and libraries are also imported. any suggestions please? This problem is also present although 10.1 and OS 10.2.1 tried.

    I thought about it... its another case of QML it can not handle.  After testing your code, I noticed this error

    file:///apps/com.example.dynamicattach.testDev_namicattach58cf113_/native/assets//main.qml:51: ReferenceError: Can't find variable: ContactSelectionMode
    

    So I tried to import ContactSelectionMode qml as the selector is with no success.

    So, I stuck with c ++ for the switch and got the results of work

    The solution

    applicationUI.cpp

    #include 
    #include 
    
    void ApplicationUI::contacts()
    {
          ContactPicker *contactPicker = new ContactPicker();
          contactPicker->setMode(ContactSelectionMode::Multiple);
          contactPicker->setKindFilters(QSet()
               << bb::pim::contacts::AttributeKind::Phone);
    
          bool success = QObject::connect(contactPicker,
                 SIGNAL(contactsSelected(QList)),
                 this,
                 SLOT(onContactsSelected(QList)));
    
          if (success) { // Signal was successfully connected.
                contactPicker->open();
              } else { // Failed to connect to signal.
                qDebug() << "Didn't connect the picker signal";
              }
    }
    
    void ApplicationUI::onContactsSelected(const QList &contactIds) {
    
        qDebug() << "contacts" << contactIds;
    }
    

    applicationUI.hpp

    public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() { }
    
        Q_INVOKABLE void contacts();
    
    public slots:
        void onContactsSelected(const QList &contactIds);
    

    . QML

    Button {
                    id: contact
                    text: "Pick Contact"
                    onClicked: {
                        cpp.contacts();
                    }
    
                }
    

    Now, given that the function is entirely in c ++, you should be able to take your code to

    _app.getContactPhoneNumber(selectedContactsIds[i]);
    

    and just insert into onContactsSelected to get your phone numbers

    I hope that helps!  Now I know how to do it too =)

    P. S.

    If you are still having a problem where something must certainly work and it is not, it is very likely that you will succeed if you just pass it to the c code ++ like theres probably a problem with the QML support.

  • Connection of signals ContactPicker

    Hello

    I can not connect the signal to a ContactPicker. Here is my code:

      ContactPicker *contactPicker = new ContactPicker();
      contactPicker->setMode(ContactSelectionMode::Multiple);
    
      bool success = QObject::connect(contactPicker,
           SIGNAL(contactsSelected(QList &)),
           this,
           SLOT(onContactsSelected(QList &)));
    
      if (success) { // Signal was successfully connected.
        contactPicker->open();
      } else { // Failed to connect to signal.
        alert(tr("Didn't connect the picker signal"));
      }
    

    I had similar problems when connecting the signal of a SystemPrompt, but I solved it by adding all the dependencies (in silence) in the hard drive file: I found an example of work and I saw everything what needs to be included. But for the ContactPicker, I can't find an example of work. Any help? Very much appreciated.

    Thank you.

    Hello

    const and & can be omitted, but they are not equal to a non-const reference.

    The following should work:

    Definition of slot:

    void onContactsSelected(const QList &contactIds);
    

    Connection:

    QObject::connect(picker, SIGNAL(contactsSelected(QList)),
                 this, SLOT(onContactsSelected(QList)));
    
  • There is no ContactPicker Signal for several ContactSelectionMode

    When I try to connect the signal "contactsSelected" of the ContactPicker to my own slot, I get:

    "Object::connect: no such signal bb::cascades:ickers::ContactPicker:contactsSelected(QList_ _&).

    QObject::connect(_contactPicker,
               SIGNAL(contactsSelected(QList &)),
               this,
               SLOT(onContactsSelected(QList &)));
    

    However, when I change the ContactPicker ContactSelectionMode "Single" and connect the signal "contactSelected" to my crack, it works very well (Contact is not the plural in this signal).

    It's the reference I used:

    http://developer.BlackBerry.com/Cascades/reference/bb__cascades__pickers__contactpicker.html#functio...

    Is it possible that the documentation for the signal name is incorrect?

    Hello

    Try declaring the slot as

        void onContactsSelected(const QList &contactIds);
    

    Change the connection to:

       QObject::connect(_contactPicker, SIGNAL(contactsSelected(QList)),
                         this, SLOT(onContactsSelected(QList)));
    
  • Contact API - results subscription to drop-down list

    I currently use the code below to get all available phone numbers and e-mail addresses for a contact:

    QVariantList ApplicationUI::getPhoneNumber(int contactId)
    {
        ContactService *contactService = new ContactService();
        Contact contactInfo = contactService->contactDetails(contactId);
        QList numberList = contactInfo.phoneNumbers();
        QVariantList no_s;
        int length = numberList.size();
    
        for (int i = 0; i < length; i++) {
            no_s << numberList.at(i).value();
        }
        return no_s;
    }
    
    QVariantList ApplicationUI::getEmailAddress(int contactId)
    {
        ContactService *contactService = new ContactService();
        Contact contactInfo = contactService->contactDetails(contactId);
        QList emailList = contactInfo.emails();
        QVariantList no_s;
        int length = emailList.size();
    
        for (int i = 0; i < length; i++) {
            no_s << emailList.at(i).value();
        }
        return no_s;
    }
    
    ContactPicker {
                id: contactPicker
                onContactSelected: {
                    contactPhoto.imageSource = _app.getContactPhoto(contactId)
                    if (contactPhoto.imageSource == "") {
                        contactPhoto.imageSource = "asset:///IMG/user_placeholder_blue.png"
                    }
                    firstName.text = _app.getFirstName(contactId)
                    surname.text = _app.getSurname(contactId)
                    phoneNumber.text = _app.getPhoneNumber(contactId).toString()
                    emailAddress.text = _app.getEmailAddress(contactId).toString()
                }
            }
    

    However, this feature is out just now all the available phone numbers and email addresses - for contact - to a text field, but I was wondering if it would be possible to output the list of individual options in a drop-down list instead of just their output in a text field?

    You will need to use ComponentDefinition and dynamically create each Option.

    Here is a code to do this:

    /*
     * Copyright (c) 2011-2014 BlackBerry 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.
     */
    
    import bb.cascades 1.2
    
    Page {
        Container {
            DropDown {
                id: dropDown
            }
            Button {
                onClicked: {
                    // Remove all options from DropDown
                    dropDown.removeAll()
    
                    // Create a VariantList to mimic a list of number returned by your C++ function
                    var listOfPhoneNumber = new Array()
                    for (var i = 0; i < 10; i++) {
                        var randomNumer = Number((Math.random() * 9000) + 1000).toFixed(0)
                        var phoneNumber = "1-555-666-" + randomNumer.toString()
                        listOfPhoneNumber[i] = phoneNumber
                    }
                    console.log("listOfPhoneNumber: " + listOfPhoneNumber)
    
                    // Iterate the list of number and add them to DropDown
                    for (var i = 0; i < listOfPhoneNumber.length; i++) {
                        var newOption = emptyOption.createObject()
                        newOption.text = listOfPhoneNumber[i]
                        dropDown.add(newOption)
                    }
                }
            }
            attachedObjects: [
                ComponentDefinition {
                    id: emptyOption
                    Option {}
                }
            ]
        }
    }
    
  • Text field in contacts

    Hello!

    I want to reuse a special text used in BlackBerry field sign on the right + card, one that shows (CC or BCC), also shows dial and uses special subcomponents to display the list of added contacts chosen of ContactPicker.

    Is it still possible?

    Best regards

    SOAman

    I guess you need to develop for yourself.

  • How to get the number and the name of the contacts selector

    Hi all

    I got the Contact Picker work but I have no idea how to get the selected telephone number and the name.

    There are attributes that I can put like contactId.value () to retrieve or there is another way?

    Thanks in advance.

    ImageButton{
                        defaultImageSource: "asset:///images/bluebutton.png"
                        onClicked: {
                            contactPicker.open();
                        }
                        attachedObjects: [
                            ContactPicker {
                                id: contactPicker
                                onContactSelected: {
                                    result.text = "You chose contact: " + contactId;
                                }
                            }
                        ]
    
                    }
    
                    Label {
                        id: result
                        text: "You chose contact: "
                    }
    

    Hello

    You can get the contact name and phone number as this,

    ImageButton{
                        defaultImageSource: "asset:///images/bluebutton.png"
                        onClicked: {
                            contactPicker.open();
                        }
                        attachedObjects: [
                            ContactPicker {
                                id: contactPicker
                                onContactSelected: {
                                    result.text = "You chose contact: " + contactId;
    // call a cpp method to get the details
    
    app.getDetails(contactId); } } ] } Label { id: result text: "You chose contact: " }
    

    the CPP code:

    void ContactDetails(ContactId id)
    {
    Contact contact_info = m_contactService->contactDetails(id);
    
        QString firstName = contact_info.firstName();
        QString lastname = contact_info.lastName();
            QList phoneno_list = contact_info.phoneNumbers();
    
        QStringList no_s;
    
        foreach(ContactAttribute attr, phoneno_list)
        {
            no_s << attr.value();
        }
    }
    

    You can get details like this.

    Kind regards

    Naresh Kodumuri.

Maybe you are looking for