PDA

View Full Version : QFileSystemModel crash when rename



stereoMatching
29th July 2012, 05:37
#include <QtCore>
#include <QtGui>

int main(int argc, char **argv)
{
QApplication app( argc, argv );

QFileSystemModel model;
QString const rootPath = "E:/file_test/very big";

QTableView view;
view.setModel(&model);
view.setRootIndex(model.setRootPath(rootPath));

QSplitter splitter;
splitter.addWidget(&view);
splitter.show();

return app.exec();
}


Under the folder "very big" consist 8448 jpg, when I using a tool(Bulk rename utility) to rename the
jpg under "very big", the program will crash. How could I stop the self updating function of QFileSystemModel?
Thanks

Added after 5 minutes:

I want to told QFileSystemModel don't update the data even there are files being renamed
Do I have to reimplement some functions of QFileSystemModel?Thanks

stereoMatching
29th July 2012, 15:48
Is this question too advance or my courtesy is no good?
I ask other questions about QFileSystemModel on this forum but rarely get responses

If I violate the rules or lack of courtesy, please tell me and I promise I will
change.Thank you very much

stereoMatching
30th July 2012, 17:24
1 : I find out the QDirModel will not update until you call "refresh"

2 : even I do not setup the model for the view, rename the files will affect
the main thread(GUI) seriously.No wonder why even I rename the files
on another thread, the GUI still stall.



int main( int argc, char **argv )
{
QApplication app( argc, argv );

QFileSystemModel model;

QString const rootPath = "E:/file_test/very big";
model.setRootPath(rootPath);

QTableView view;
//I haven't set any model for The view, but the program still
//crash if I rename 8448 of my jpg files by other program

QSplitter splitter;
splitter.addWidget(&view);
splitter.show();

return app.exec();
}


There are still more than 1XX pages of the model/view architecture I have to studied(advanced Qt programming)
I hope I could know how to prevent the automatic "refresh" function of the QFileSystemModel after
I finish the chapter 4, 5, 6 in the book

QDirModel is not a good solution, but looks like it could solve my problem for now.

Never expect that customize the model/view of Qt4 could be so complicated(2XX pages to study)
And I am still a newbie of Qt...