How to detect Scroll Up intention
-
wrote on 19 Jan 2019, 15:35 last edited by
Hi all,
I am creating a chat application, and when my user opens the conversation only the last 20 messages are displayed. What I want to do, is when the user scrolls up , show him the previous messages, kind of like WhatsApp does.
I am using ListView item in QML (QtQuick2), and I need to detect that the user has made an intention to scroll higher than current amount of messages and upon detecting this event, launch a call to the server to get the messages.
What signal/slots should I use to achieve this behaviour?
(I working with Android and Desktop platforms)TIA
-
Hi all,
I am creating a chat application, and when my user opens the conversation only the last 20 messages are displayed. What I want to do, is when the user scrolls up , show him the previous messages, kind of like WhatsApp does.
I am using ListView item in QML (QtQuick2), and I need to detect that the user has made an intention to scroll higher than current amount of messages and upon detecting this event, launch a call to the server to get the messages.
What signal/slots should I use to achieve this behaviour?
(I working with Android and Desktop platforms)TIA
-
wrote on 19 Jan 2019, 18:14 last edited by
@raven-worx said in How to detect Scroll Up intention:
@Nulik
Are you using a C++ (QAbstractItemModel) for your QML ListView?
If so the ListView calls fetchMore() on the model when scrolled to the end.Yes , I am using C++ class with QAbstractItemModel as parent class.
ListView inherits Flickable QML type, which does the scrolling and provides various properties and signals
ok, will look at that, thanks!
-
@raven-worx said in How to detect Scroll Up intention:
@Nulik
Are you using a C++ (QAbstractItemModel) for your QML ListView?
If so the ListView calls fetchMore() on the model when scrolled to the end.Yes , I am using C++ class with QAbstractItemModel as parent class.
ListView inherits Flickable QML type, which does the scrolling and provides various properties and signals
ok, will look at that, thanks!
@Nulik
so in that case you simply need to implement canFetchMore() and fetchMore().
in fetchMore() method you need to request the data. When you receivedthe data simply insert the rows into the model with beginInsertRows()/endInsertRows().
The rest is already handled by ListView
1/4