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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums on April 1st. BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com


Reply
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2
Accepted Solution

Convert int value from sql to QString without using C++

Hi, I am having some trouble passing an integer value into my list. I am relying entirely on QML and would rather not touch C++ as they tend to create more problems for me sometimes. Smiley Frustrated

 

I need to load data such as: Int ID, string Otherdata into my GroupDataModel.

 

Problem is:

1) I use the ID as a sorting key

AND

2) I want to display it on my List as well. 

 

I found another solution that calls for the values to be stored as "001, 002, 003" etc. but as I mentioned, I would like to display the information and this is not viable. 

 

I am wondering if I can perhaps use javascript to convert such string? I tried looking for some Qt solutions btu they are all highly reliant on C++ and I do not wish to touch that. 

 

I tried:

 function convertInt (data){return QString(%1).arg(ListItemData.CategoryID || "")}

 But it doesn't seem to work at all...

 

I have also tried ListItemData.CategoryID.toString() but it doesn't work as well... 

 

Can someone please help? Thanks!

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Convert int value from sql to QString without using C++

You shouldn't have to convert it at all, what control are you trying to use it in?

 

Just

 

  text:ListItemData.CategoryID

 

should work.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Convert int value from sql to QString without using C++

Yes, but it is showing up as 'undefined'. Here is my list code;

 

ListView {
                dataModel: GroupDataModel {id: dataModelnew
                    sortingKeys: ["CategoryID", "InvItemID"]
                    grouping: ItemGrouping.ByFullValue
                }
                function itemType(data, indexPath){
                return (indexPath.length == 1? "header" : "item")}
                listItemComponents: [
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: "Category " + ListItemData.CategoryID
                        }
                    },
                    ListItemComponent {
                        type: "item"
                        CustomListItem {
                            dividerVisible: false
                            Container {
                                background: Color.White
                                clipContentToBounds: false
                                Label {text: ListItemData.InvItemName}
                            }
                        }
                    }
                
                ]
            
            }

 I am just wondering if there might be anything to do with the indexPath? The thing is I am using an sql database and I am not entirely sure how the data is mapped out.

Highlighted
Developer
Posts: 74
Registered: ‎12-17-2009
My Device: Z30
My Carrier: O2

Re: Convert int value from sql to QString without using C++

After hours of trial and error, I've finally managed to get the CategoryID to show.

Instead of referring to it as ListItemData.CategoryID, I just used: ListItemData under the header ListItemComponent.

I have also removed the function itemType as it don't seem necessary here atm.

Apparently it is kind of 'automatic' by putting in the the CategoryID in the sortingKeys and grouping.