Select files, from all selected items in a TreeView ...

  • Hi;
    By pressing a push-button, I would like to retrieve all selected items in my TreeView and then I want to do something , if the selected item is file , directory or drive...
    Here is my codes:

    void MainWindow::on_pushButton_clicked()
        QModelIndexList list = ui->myTreeView->selectionModel()->selectedRows();
        foreach(QModelIndex index, list)
            QFileInfo fileInf=;
            // Here I want to check if the selected item is a file :        
            qDebug() << fileInf.fileName();

    The " qDebug() << fileInf.fileName(); " shows name of everything ( file-name , Folder-name and Drive name ..! ). I put " if ( fileInf.isFile() ) ... " , but it does not works.


  • Lifetime Qt Champion


    What exactly doesn't work ?

Log in to reply

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