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 Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil
Accepted Solution

How to scroll to an item in ListView

I have a ListView with a GroupDataModel (one dimension). I would like to have it scrolled to particular item when it appear. Unfortunatelly neither

 

ListView {
   .
   .
  onCreationCompleted: {
      scrollToItem(QVariantList() << x, ScrollAnimation.None);
  }
   .
   .
}

nor

ListView {
   .
   .
  onCreationCompleted: {
      select(QVariantList() << x, true);
  }
   .
   .
}

 works. (x is a simple number) What can I do else?

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to scroll to an item in ListView

That's C++ syntax. In QML/JavaScript it would be

idOfListView.scrollToItem([x], ScrollAnimation.None)
or
idOfListView.scrollToItem([0, x], ScrollAnimation.None)

Andrey Fidrya, @zmeyc on twitter
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil

Re: How to scroll to an item in ListView

Ah, thanks.