Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QML ListView with sticky date indicator
alexej.k last edited by
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?
shaan7 last edited by
I haven't attempted to replicate your use-case but using
ListViewsections and displaying the
currentSectionin a Label as
headerPositioning: ListView.OverlayHeadershould help.