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
Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Setting QML objectName for StandardListItem properties

Hi,

 

In the StandardListItem, I can set the value of title,description and imageSource

 

but is there any way of assiging an 'objectName' to them, so that the same can be retrieved and changed from the C++ code.

 

What I'n trying is, I have QML like

 

StandardListItem{
title:{
objectName:ListItemData.indexValue
}
}

 And so, with  each title having different indexValue, I can do something in C++

findChild<>("indexValue)

--set property.

 

Is there any way this can be acheived?

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Setting QML objectName for StandardListItem properties

Did you test it by yourself? Did you get an error in IDE? Can you try objectName: "" + ListItemData.indexValue?
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Setting QML objectName for StandardListItem properties

No, I havent tried it myself to check any errors.

As I mentioned that my main objective is "but is there any way of assiging an 'objectName' to them, so that the same can be retrieved and changed from the C++ code"

So, happy to use any approach that i get as recommendation which would help me achieve the objective.
Highlighted
Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Setting QML objectName for StandardListItem properties

Every QObject has its own objectName so the answer is: Yes :-)
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Setting QML objectName for StandardListItem properties

[ Edited ]

Tried it, but unfortunately doesn't seems to be true to confirm

My GroupDataModel

map["title"]
map["description"]
map["index"]

StandardListItem {
title: {
text:ListItemData.title
// objectName: "title"+ListItemData.index
}
description: {
text: ListItemData.description
//objectName:ListItemData.index+"description"
}
imageSource: {
image: "asset:///images/picture.png"
//objectName:ListItemData.index+"img"
}
}

 


As soon as I uncoment the objectName lines from the StandardList, the rendering fails and starts dispalting title and text like 'parser data' for all texts and blank for images.

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Setting QML objectName for StandardListItem properties

I will check that in the evening and then tell you my findings.
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Setting QML objectName for StandardListItem properties

any updates coming up on this?

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Setting QML objectName for StandardListItem properties

Both 'title' and 'objectNames' are QML properties. It is true that all QObjects have 'objectName's, but title is a QString, not a QObject. you cannot set an objectName on a title - will need to dig deeper for something that can help what you are doing;

Retired
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Setting QML objectName for StandardListItem properties

I see you want to hold titles, descriptions and indices in maps - I am not sure what you wish to achieve, but you could always hold the objectNames of the StandardListItems themselves, use that into your map and populate/manipulate titles, descriptions and indices from there;

Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Setting QML objectName for StandardListItem properties

I've put objectName property into StandardListItem compont instead into title, description and imageSource, but in C++ I always get 0 (null) for the pointer pointing to list item when searching by its objectName.

There is no problem with list view.
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development