[Qt-interest] QListWidget increasingly slow

Bob Hood bhood2 at comcast.net
Tue Nov 10 19:43:41 CET 2009


I'm looking for some advice here.  I'm using a QListWidget as a log
window, and for short output, it's fine.  However, when I get into
thousands of lines, it slowly grinds my application to halt as lines are
added to it.

I know the culprit, though.  I've narrowed it down to the
setCurrentRow() method:

    log_list->addItem(msg);
    log_list->setCurrentRow(log_list->count() - 1);

I am using setCurrentRow() to keep the most recent item in the list
visible to the user as entries are added.  If I remove this call,
everything runs comparatively smoothly -- but entries being added are
not visible unless the user manually drags the scroll bar down.  I've
also tried using setCurrentItem() to keep things visible, with the same
asymptotic results.

Is there a more efficient way to keep most-recent entries visible using
QListWidget?  I'm using QListWidget so I can colorize entries, and add
icons to the lines, so if there's a better Qt widget for displaying
thousands of lines of text that would give me the same features
(colorization and icons), then I'd be happy to try it.

Render me gone,                       |||
Bob                                 ^(===)^
---------------------------------oOO--(_)--OOo---------------------------------
  The brain is a wonderful organ; it starts working the moment you get up in
  the morning and does not stop until you get to the office.  - /Robert Frost/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091110/459bb2ff/attachment.html 


More information about the Qt-interest-old mailing list