Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QFileDialog
Qt 6.11 is out! See what's new in the release blog

Problem with QFileDialog

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 442 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • martial123M Offline
    martial123M Offline
    martial123
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • martial123M martial123

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @martial123
      Manipulate the returned path by adding:

      fileName = QFileInfo(fileName).fileName();
      
      1 Reply Last reply
      4
      • martial123M Offline
        martial123M Offline
        martial123
        wrote on last edited by
        #3

        Thank you !!!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved