Hi,
From: Bernhard B <[email protected]> To: <[email protected]> Sent: 1/26/2017 8:09 PM Subject: Re: [Development] Improve performance (listview + onVerticalVelocityChanged) I think I solved my problem. In case someone is interested, that's my solution: //hide "back to top" button when movement ended and we are//at index 0onMovementEnded: { if(indexAt(contentX, contentY) === 0){ backToTopButton.visible = false; }} onFlickStarted: { //when user scrolls fast enough up, show the tab bar //and the "back to top" button if(verticalVelocity < -flickTabBarTreshold) { backToTopButton.visible = true; tabBar.show(); } //when user scrolls fast enough down hide "back to top" button //and the tab bar if(verticalVelocity > flickTabBarTreshold){ backToTopButton.visible = false; tabBar.hide(); }} I don't know if this is the best solution, but it seems to work. I guess you could also bind the visibility of your backToTopButton/tabBar to the ListView properties atYBeginning, flickingVertically and the comparison of the verticalVelocity against your threshold. Just as an info: the 'development' list is for questions regarding the development of Qt itself, questions regarding the usage of Qt should go to the 'interest' list. More people will respond there. Thanks, Bernhard Regards Martin 2017-01-26 15:38 GMT+01:00 Bernhard B <[email protected]>: Hi, I am currently trying to optimize my Listview for performance. I already removed most of the bottlenecks by following the great recommendations at: http://doc.qt.io/qt-5/qtquick-performance.html However, there is one problem I don't how to solve. It's about this code part: ListView{ clip: true property real flickTabBarTreshold; Component.onCompleted: { flickTabBarTreshold = (2/3) * maximumFlickVelocity; } onVerticalVelocityChanged: { //when user scrolls fast enough up, show the tab bar //and the "back to top" button if(verticalVelocity < -flickTabBarTreshold) { backToTopButton.visible = true; tabBar.show(); } //when user scrolls fast enough down hide "back to top" button //and the tab bar if(verticalVelocity > flickTabBarTreshold){ backToTopButton.visible = false; tabBar.hide(); } //always disable "back to top button" when top reached if(indexAt(contentX, contentY) === 0) backToTopButton.visible = false; } } This part is one of the biggest performance bottlenecks at the moment (as it gets called a lot of times) and has a significant impact on the scrolling behavior (lagging). My idea was to put that code somehow in my C++ Listmodel and emit only a signal when something actually changed. For the last part //always disable "back to top button" when top reached if(indexAt(contentX, contentY) === 0) backToTopButton.visible = false; I think it should be possible to check that in the QVariant QAbstractItemModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const method. When index.row() === 0, I a signal will be emitted. In QML I am connecting on that signal and execute backToTopButton.visible = false; I haven't tested it yet, but I think it should work. For the other two conditions however, I am a little bit clueless. Does anyone of you guys maybe have an idea on how to improve that? Any help is really appreciated. Thanks, Bernhard _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
