Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to detect Scroll Up intention
Forum Updated to NodeBB v4.3 + New Features

How to detect Scroll Up intention

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nulik
    wrote on 19 Jan 2019, 15:35 last edited by
    #1

    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

    R 1 Reply Last reply 19 Jan 2019, 17:14
    0
    • N Nulik
      19 Jan 2019, 15:35

      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

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 19 Jan 2019, 17:14 last edited by
      #2

      @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.

      ListView inherits Flickable QML type, which does the scrolling and provides various properties and signals

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      N 1 Reply Last reply 19 Jan 2019, 18:14
      3
      • R raven-worx
        19 Jan 2019, 17:14

        @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.

        ListView inherits Flickable QML type, which does the scrolling and provides various properties and signals

        N Offline
        N Offline
        Nulik
        wrote on 19 Jan 2019, 18:14 last edited by
        #3

        @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!

        R 1 Reply Last reply 19 Jan 2019, 18:20
        0
        • N Nulik
          19 Jan 2019, 18:14

          @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!

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 19 Jan 2019, 18:20 last edited by
          #4

          @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

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          3

          1/4

          19 Jan 2019, 15:35

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved