Important: Please read the Qt Code of Conduct -

Problem with QFileDialog

  • Hi everyone,

    I would like to recover the name of the file load like this :

       QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "/home", tr("All files (*.*);;Excel files (*.csv)(*.xlsx)"));

    in order to show in QMessageBox::information this name.

    My problem is : when i show fileName QString, Ihave all path for my load file..

    I just want to recover the last argument of this path ( the name of file and his extension...)

    Thank you

  • @martial123
    Manipulate the returned path by adding:

    fileName = QFileInfo(fileName).fileName();

  • Thank you !!!

Log in to reply