Qt Code:
  1. #include <QApplication>
  2.  
  3. #include <QDir>
  4. #include <QFileSystemModel>
  5. #include <QString>
  6. #include <QTableView>
  7. #include <QTreeView>
  8.  
  9. int main( int argc, char **argv )
  10. {
  11. QApplication app( argc, argv );
  12.  
  13. QFileSystemModel model;
  14. QString const rootPath = "E:/file_test/very big";
  15.  
  16. QTableView view;
  17. view.setModel(&model);
  18. view.setRootIndex(model.setRootPath(rootPath));
  19.  
  20. view.show();
  21. //....select the data you want to rename from the view
  22. //let us assume I select 8000 of jpg files
  23.  
  24. //don't know how to rename the file by QFileSystemModel, so I use QFile instead
  25. QDir::setCurrent(rootPath);
  26. model.blockSignals(true);
  27. view.blockSignals(true);
  28. for(int i = 0; i != 8000; ++i)
  29. {
  30. QFile file(rootPath + "/kkk" + QString::number(i) + ".jpg");
  31. file.rename("jjj" + QString::number(i) + ".jpg");
  32. }
  33. model.blockSignals(false);
  34. view.blockSignals(false);
  35.  
  36. //the program will stall
  37. qDebug() << "finish";
  38.  
  39. return app.exec();
  40. }
To copy to clipboard, switch view to plain text mode 

The UI would stall (become "blank" one before the the all of the files have changed their name)
I do try multi-thread (boost::thread) and QTimer::singleShot, but it is still stallif
besides, if I using multi-thread if will emit warning like "it is unsafe to use QPixmap in other
thread", so I better don't use it.

I added a progress bar to show the progress, but the progress bar also stall
How could I make the UI become alive when the files being rename?Thanks