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
xtomi
Posts: 2
Registered: ‎04-21-2013
My Device: Z10

contactPicker - QML - ContactSelectionMode.Attribute

Hi,

 

is there any QML example how to use " ContactSelectionMode.Attribute" mode? I have used this code:

 

attachedObjects: [
                ContactPicker {
                    id: contactPicker
                    mode: ContactSelectionMode.Attribute
                    title: qsTr("Chose contact please:")
                    onContactAttributeSelected: {
                        callingNumber.text = attribute.value    ;
                    }
                }

 

but without sucess (picker dialog open, but i can't select any item).

 

Thanks a lot.

New Contributor
ssitwell
Posts: 3
Registered: ‎04-28-2013
My Device: Z10

Re: contactPicker - QML - ContactSelectionMode.Attribute

 

 

I could at least solve part of the puzzle. I think the mode needs to be put in quotes, mode: "Multiple". This works for multiple. I tried for attributes, but the picker didnt go to contact details so that attributes could be selected.

 

New Contributor
xtomi
Posts: 2
Registered: ‎04-21-2013
My Device: Z10

Re: contactPicker - QML - ContactSelectionMode.Attribute

[ Edited ]

Hi, yes, you are right, "multiple" works. But i had no success with that Attribute. Finaly i had to create function in C++ and call the function from QML:

 

C++ function:

 

void myUtils::getNumberFromPicker() {
		ContactPicker* contactPicker = new ContactPicker();
	    contactPicker->setMode(ContactSelectionMode::Attribute);
	    contactPicker->setKindFilters(QSet<bb::pim::contacts::AttributeKind::Type>() << bb::pim::contacts::AttributeKind::Phone);
	    bool success=QObject::connect(contactPicker, SIGNAL(contactAttributeSelected(bb::cascades::pickers::SelectedContactAttribute)), this, SLOT(onContactAttributeSelected(bb::cascades::pickers::SelectedContactAttribute)));
	    Q_ASSERT(success);
	    contactPicker->open();
	    Q_UNUSED(success);
//	    qDebug() << "Hello1";
//	    return 1;
}

 And than signal "processing":

 

void myUtils::onContactAttributeSelected(SelectedContactAttribute newCheckedState) {
    //calledNumber = "11123456789";
     calledNumber = newCheckedState.value();
     myTextField->setText(calledNumber);
//     emit calledNumberUpdated(calledNumber);
    //     qDebug() << pokus;
}

 

 

 

 

 

BR, T.