Nominate our 2022 Qt Champions!

QListview flickers when model updates in another thread

  • I am updating my QStandardItemModel in a separate thread but QListView flickers while it updates. I am using QtConcurrent::run to do that, its dumb question but will it make any better if I do using QThread instead? IS there a way to remove the flicker?

    // somewhere on button click. I start the search in a separate thread which updates the model
    @void MainWindow::on_pushButtonConvert_clicked()
    // ...
    QtConcurrent::run( this, &MainWindow::convertXmlFiles, sourceDir.absolutePath(), destDir.absolutePath() ) ;

    @int MainWindow::searchXmlFiles(QString rootDir)

    int count = 0;
    QString xmlFilePath;
    QDirIterator iter( rootDir, QStringList() << "*.xml", QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
    QDir dir( rootDir );
    while(iter.hasNext() )
        xmlFilePath = iter.filePath();
        QStandardItem * item = new QStandardItem( QIcon(":/icons/Progeny.ico") , dir.relativeFilePath( xmlFilePath) );
        appendRow( item );
    return count;


  • Lifetime Qt Champion


    You should not update your models directly from a different thread. Both view and model should live in the GUI thread. Some more information "here":

Log in to reply