1
votes

I want to write a "infinite scrolling" list widget. The scrolling should happen automatically based on a timer. There won't be any user-interaction. The list contains items 0-100 for example. If the scroll-area reaches item 100 the next item being shown should be item 1 and so on (like a scrolling text sign).

I hope you get what I want ;)

How can I implement this in a subclass of QListWidget? Or is it better not to use QListWidget and write my own class to do this?

1

1 Answers

1
votes

You don't need to subclass. The simplest implementation is simply to clear and fill the QListWidget from whatever widget you are filling the list (could be your main window). The drawback is that it probably looks messy on screen.

Another option is a QPlainTextEdit; set a maximum line count with setMaximumBlockCount(), then call appendPlainText() (or appendHtml)) at each timer tick. The old lines will disappear when you reach the maximum count of lines, so it you start at 0 again at the right time it will look like it's cycling through the entries.

If it has to be a list, try a QListView with a proxy (QAbstractProxyModel) that displays your entries with a variable offset and wraps around.