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.1k 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 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

    raven-worxR 1 Reply Last reply
    0
    • N Nulik

      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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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
      3
      • raven-worxR raven-worx

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

        raven-worxR 1 Reply Last reply
        0
        • N Nulik

          @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-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on 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

          • Login

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