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
Forum Update on Monday, May 27th 2025

Problem with QFileDialog

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 313 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.
  • M Offline
    M Offline
    martial123
    wrote on 6 Feb 2020, 21:00 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

    J 1 Reply Last reply 6 Feb 2020, 21:48
    0
    • M martial123
      6 Feb 2020, 21:00

      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

      J Offline
      J Offline
      JonB
      wrote on 6 Feb 2020, 21:48 last edited by JonB 2 Jun 2020, 21:49
      #2

      @martial123
      Manipulate the returned path by adding:

      fileName = QFileInfo(fileName).fileName();
      
      1 Reply Last reply
      4
      • M Offline
        M Offline
        martial123
        wrote on 7 Feb 2020, 11:35 last edited by
        #3

        Thank you !!!

        1 Reply Last reply
        0

        2/3

        6 Feb 2020, 21:48

        • Login

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