Find if file exists in QFileSystemModel.



  • 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 do

    int 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.