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. Extracting information from file path
Qt 6.11 is out! See what's new in the release blog

Extracting information from file path

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 889 Views 1 Watching
  • 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
    mena_mes
    wrote on last edited by mena_mes
    #1

    Hi,

    Is there a function in QFile that return the path of the file?

    for example for "c:/external/xml/file.txt" I want to extract only "c:/external/xml".

    thanks in advance

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Use QFileInfo or QDir. For example:

      QFile someFile;
      QFileInfo info(someFile.fileName());
      QString xmlDir = info.absolutePath();
      // xmlDir == "c:/external/xml".
      

      (Z(:^

      M 1 Reply Last reply
      3
      • sierdzioS sierdzio

        Use QFileInfo or QDir. For example:

        QFile someFile;
        QFileInfo info(someFile.fileName());
        QString xmlDir = info.absolutePath();
        // xmlDir == "c:/external/xml".
        
        M Offline
        M Offline
        mena_mes
        wrote on last edited by
        #3

        @sierdzio thank you so much

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          You're welcome. Happy coding :-)

          (Z(:^

          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