Find if file exists in QFileSystemModel.
-
wrote on 15 Mar 2016, 07:10 last edited by tokafr
Hi
I want to to create a Folder with mkdir of QFileSystemModel. But I want to create with name "New Folder" and if "New Folder" already exists create "New Folder(1)". So Firstly I want to find out it "New Folder" already exists. How can I find it?
for now I doint count = 0; QModelIndex fileIndex = FileModel_ -> index(nameToCheck); while (FileModel_ -> fileInfo(fileIndex).exists()) { nameToCheck = name + "(" + (++count) + ")"; fileIndex = FileModel_ -> index(nameToCheck); } FileModel_ -> mkdir(parentDir, nameToCheck);
Where FileModel_ is an object of QFileSystemModel.
thanks
1/1