[Qt-interest] QListWidget increasingly slow
Josiah Bryan
jbryan at productiveconcepts.com
Tue Nov 10 19:50:28 CET 2009
Bob Hood wrote:
> 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.
Have you thought about using a QTextEdit and using html to colorize the
lines and add icons? Use the QTextCursor interface to append html to the
document.
Line with icon html:
<div style='background:red;color:white'><img src=':/data/icon.png'>
Hello World!</div>
Then just set the viewport's scroll bar position to the bottom when you
add text.
HTH. Cheers!
-josiah
>
> 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/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
--
-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
jbryan at pciint.com
(765) 964-6009, ext. 224
More information about the Qt-interest-old
mailing list