Yes, it doesn't update because of the busy loop which blocks the event loop. Paint events get scheduled but you are not giving the application any chance to actually deliver them. Behind the curtains the view gets informed about each and every insertion. This is most likely one of main reasons why it takes so long to insert items one by one. Could you give QListWidget::addItems() a try? If it's still too slow, we'll look for other possibilities.
for (int i = 0; i < 1000; ++i)
listWidget->addItem(something); // each item added separately, view gets informed thousand times, once per insertion
for (int i = 0; i < 1000; ++i)
listWidget->addItem(something); // each item added separately, view gets informed thousand times, once per insertion
To copy to clipboard, switch view to plain text mode
for (int i = 0; i < 1000; ++i)
items += something;
listWidget->addItems(items); // everything gets inserted at one go, view gets informed only once in total
QStringList items;
for (int i = 0; i < 1000; ++i)
items += something;
listWidget->addItems(items); // everything gets inserted at one go, view gets informed only once in total
To copy to clipboard, switch view to plain text mode
Bookmarks