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: 154
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha
My Carrier: SFR

Custom ListView & QVariantList (QML)

Hi,

 

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) {
        myselectchanged(indexPath);
      }
    }
  }
}

 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

etc...

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

 

Nicolas

 

Retired
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?

 

Stuart

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

Re: Custom ListView & QVariantList (QML)

Nope,

 

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.

 

Nicolas

 

Developer
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.

 

QML
signal selectChanged(variant v)

C++
void App::onSelectChanged(QVariant &_v)
{
    QVariantList v = _v.toList();
}