سؤال

This happens when I add items one at a time (adding one item and then returning to the event loop). To illustrate, my code looks roughly like this:

    ....................
    timer = new QTimer(this);
    timer->setInterval(0);
    connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
    ....................

void Dialog::onTimeout()
{
    QListWidgetItem* item = new QListWidgetItem;

    ....................

    ui->listWidget->addItem(item);
}
هل كانت مفيدة؟

المحلول

The code look OK to me. I ran it on my local machine and it executed without flickering. Are you dealing with intense graphics (even this should be OK due to the way Qt defines timeout(0)... as it waits for event queue to complete)? Most likely there is other code that is the culprit.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top