Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make QML ListView cyclic?

Tags:

c++

qt4

qml

I've implemented a simple list model and list delegate in QML, and now curious if it feasible to make the underlying list cyclic. Here is the code snippet:

      Common.MarketsListView {
      id: markets
      anchors.top: logoImage.bottom
      anchors.topMargin: 5
      cacheBuffer: 20000

      NumberAnimation on x {
          running: runtime.isActiveWindow
          loops: Animation.Infinite
          from: 0
          to: -300
          duration: 20000
      }

Currently, the list slowly moves to the left, but as it reaches the end only few last items are shown. So I shall either make the underlying list cyclic, or hard-code the jump to the first list item :(

like image 608
MadH Avatar asked Nov 19 '10 12:11

MadH


People also ask

What is ListView in QML?

A ListView displays data from models created from built-in QML types like ListModel. A ListView has a model, which defines the data to be displayed, and a delegate, which defines how the data should be displayed. Items in a ListView are laid out horizontally or vertically.

What is QML delegate?

delegate : Component. The delegate provides a template defining each item instantiated by a view. The index is exposed as an accessible index property. Properties of the model are also available depending upon the type of Data Model.


1 Answers

You can't do this with a ListView, but you may be able to get the bahavior you want using PathView, e.g. https://doc.qt.io/archives/qt-4.7/declarative-ui-components-spinner.html

like image 102
MartinJ Avatar answered Oct 04 '22 21:10

MartinJ