Change Item in ListView in a time interval
-
How can I change the showing item after a while?
The interval could be set through a json file?Thanks ;)
-
You can use "QTimer":https://qt-project.org/doc/qt-5/qtimer.html#details
@
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateListView()));
timer->start(1000);
@ -
It's possible to solve this problem just using QML? Or QML and Javascript?
Thanks for your quickly answer! ;) -
hi, there is a QML Timer object wrapper for QTimer, so yes you can use the timer in QML without any c++: http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-timer.html
-
Hi, thank you!
I tried your solution. But I'm quite newbie. Here what i'm trying to do.
@Item {
id: root
property string name
property bool isSelected: listView.currentIndex === index
Timer {
interval: 5000; running: true; repeat: true
onTriggered: listView.currentIndex = currentIndex + 1
}@When I run the file, I got this error:
[...] SlideItem.qml:11: ReferenceError: currentIndex is not defined
ps 1.: I am changing the Cinematic Experience (http://quitcoding.com/?page=work)
ps 1.: What I'm trying to do is a slideshow program
-
currentIndex should work if your listView ID is correct!? weird
but I guess you need that inside of the delegate of the ListView? then you should use the attached property "isCurrentItem":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-listview.html#isCurrentItem-prop anyways.
Also you can use "listView.incrementCurrentIndex()":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-listview.html#incrementCurrentIndex-method instead of "listView.currentIndex = currentIndex + 1". :)
-
Thank you for the tip!
In my MainView.qml I set the listView ID
@ListView {
id: listView// property real globalLightPosX: lightImage.x / root.width // property real globalLightPosY: lightImage.y / root.height // Normal-mapped cover shared among delegates // ShaderEffectSource { // id: coverNmapSource // sourceItem: Image { source: "images/cover_nmap.png" } // hideSource: true // visible: false // } anchors.fill: parent // spacing: -60 model: slidesModel delegate: SlideItem { name: model.name } highlightFollowsCurrentItem: true highlightRangeMode: ListView.StrictlyEnforceRange highlightMoveDuration: 400 // preferredHighlightBegin: root.height * 0.5 - 140 // preferredHighlightEnd: root.height * 0.5 - 140 cacheBuffer: 4000 }@
Thats correct right?
I do not understand the use of isCurrentItem in my case.---- EDIT----
Hey! It works when I changed to listView.incrementCurrentIndex()
But it jumps to a item that it's not the next one. -
Hi again!
I notice that the next item when the interval ends, it's the fifth element item. How can I correct this? It's very strange because I'm using incrementCurrentIndex() method.