Re: [Development] Improve performance (listview + onVerticalVelocityChanged)

2017-01-30 Thread Ulf Hermann

Am 26.01.2017 um 20:09 schrieb Bernhard B:
I think I solved my problem. In case someone is interested, that's my 
solution:


Can't you bind the "visible" properties to the velocity? Then it doesn't 
have to execute so much javascript and the code looks cleaner and more 
declarative. The bindings will still be executed on every change in 
velocity, but it's likely that they'll be better optimized:


Something {
id: backToTopButton
visible: listView.verticalVelocity < -flickTabBarThreshold
}

SomethingElse {
id: tabBar
visible: backToTopButton.visible
}

br,
Ulf
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Improve performance (listview + onVerticalVelocityChanged)

2017-01-27 Thread Martin Leutelt
Hi,


 From:   Bernhard B <schluc...@gmail.com> 
 To:   <development@qt-project.org> 
 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 <schluc...@gmail.com>:






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 , 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 
Development@qt-project.org 
http://lists.qt-project.org/mailman/listinfo/development 
___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Improve performance (listview + onVerticalVelocityChanged)

2017-01-26 Thread Bernhard B
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 0

onMovementEnded: {
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.

Thanks,
Bernhard

2017-01-26 15:38 GMT+01:00 Bernhard B :

> 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 reachedif(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
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] Improve performance (listview + onVerticalVelocityChanged)

2017-01-26 Thread Bernhard B
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
reachedif(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
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development