QML ListView with sticky date indicator



  • Hi,

    I am building a chat window in QML and am using a (clipped) ListView to display the chat history.

    In the ListView, between the chat messages I have special separator delegates which display the day for all following messages (e.g. "Today" or "May 1st"), just like in WhatsApp or Telegram. I would like to "pin" these elements to the top of the list such that the right date is always displayed while the user is scrolling through the history. Whenever the user reaches a new day in the history, the old pinned element should be replaced by the new one.

    Is there any efficient way to find out which element is currenty displayed on top of the ListView area, such that I can find out which day's messages are currently displayed?

    Thanks



  • I haven't attempted to replicate your use-case but using ListView sections and displaying the currentSection in a Label as header with headerPositioning: ListView.OverlayHeader should help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.