문제

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