QListWidget - Auto Scroll
-
wrote on 16 Nov 2010, 22:36 last edited by
Hi all!
I am using a QListWidget to display various messages in a lightweight server application. However one tiny cosmetic problem is really irritating me,
As items are being added to the list the vertical scrollbar will not automatically scroll down to always show the latest message at the bottom of the QListWidget. There appears to be an 'autoscroll' option in the design properties of the QListWidget but I'm yet to understand what this does.
Could anybody help please??
Much Love
Andrew -
wrote on 16 Nov 2010, 22:53 last edited by
Did you try to call "QAbstractItemView::scrollToBottom()":http://doc.qt.nokia.com/4.7/qabstractitemview.html#scrollToBottom after you have added an item? (the function is available in all subclasses, including QListWidget).
-
wrote on 16 Nov 2010, 22:59 last edited by
Yes my issue is more how can I do this using connect() signals and slots as nearly all methods and several classes are pumping data into this QListWidget so it would be much easier to simply signal the system to do it.
Thanks
Andrew -
wrote on 16 Nov 2010, 23:18 last edited by
You can try this (I did not try it myself):
@
connect(
listView->model(),
SIGNAL(rowsInserted ( const QModelIndex &, int, int ) ),
listView,
SLOT(scrollToBottom ())
);
@ -
wrote on 16 Nov 2010, 23:26 last edited by
That worked perfectly first time, your a star. Thank You :-D
-
wrote on 16 Nov 2010, 23:31 last edited by
Oh wow... I'd rather believe I did too much (sometimes fance, sometimes not so fancy) stuff with list views in the last years :-)
-
wrote on 5 Apr 2017, 12:52 last edited by
When you frequently add lines to the model, the widget starts to slow down. You can make setUniformItemSizes(), but I want the elements to be of different heights.
There is a solution?