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

Posts: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR

Custom ListView & QVariantList (QML)



I want to create a custom component in QML to be used from C++ side.


Container {
  signal myselectchanged(... indexPath)   <= I don't know what I have to write

  ListView {
    onSelectedChanged: {
      if (selected) {

 I don't want bind the default selectchanged signal ; otherwise my C++ code knows the QML code.


All work for a basic type (bool, string...) but I don't know the qml type of indexPath variable.


We can map :

QT - QString <===> QML - string

QT - bool <====> QML - bool


QT - QVariantList <====> ?????




Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Custom ListView & QVariantList (QML)

Check out https://developer.blackberry.com/cascades/documentation/ui/lists/list_view.html


Scroll to the bottom and read the last section: Using the index path to respond to selection


Is this what you are trying to do?



Posts: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR

Re: Custom ListView & QVariantList (QML)



I know how to connect to selectChanged native signal :


QObject::connect(listView, SIGNAL(selectChanged(QVariantList)), this, SLOT(onSelectChanged(QVariantList)));

 But, in my case, I want to use a custom signal. I have done a custom component in QML who contains a ListView (see my first post).


My issue is : how to define the signal prototype in the QML code ?


I want to avoid that my C++ knows that my custom component contains a ListView.




Posts: 18
Registered: ‎04-28-2012
My Device: Playbook & Dev Alpha
My Carrier: AIS

Re: Custom ListView & QVariantList (QML)

[ Edited ]

Use variant in QML and QVariant in C++. Then in C++ function, call QVariant::toList() to convert it to QVariantList. For example.


signal selectChanged(variant v)

void App::onSelectChanged(QVariant &_v)
    QVariantList v = _v.toList();