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 QFileInfo::absolutePath() and relative paths as input
Forum Updated to NodeBB v4.3 + New Features

Problem with QFileInfo::absolutePath() and relative paths as input

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 1.1k 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.
  • S Offline
    S Offline
    stvokr
    wrote on last edited by
    #1

    Hi all,

    I think QFileInfo does not return the absolute path as desired using relativ paths! Why?
    Windows 7, Qt 5.3.2 and Qt 5.6

    I want the absolute path of a directory and an file (both of them as absolute and relative path as input to the QFileInfo).
    I think there must be is a "/" at the end to differ between files and directory.

    // My application dir is D:/Test/User/Project.
    
    // absolute path as input
    QString dir1 = QFileInfo( "D:/Test/User/Project/test" ).absolutePath();
    QString dir2 = QFileInfo( "D:/Test/User/Project/test/" ).absolutePath();
    
    // relative path as input
    QString dir3 = QFileInfo( "./test" ).absolutePath();
    QString dir4 = QFileInfo( "./test/" ).absolutePath();
    

    This is what I get

    dir1 = "D:/Test/User/Project/"
    dir2 = "D:/Test/User/Project/test/"
    
    dir3 = "D:/Test/User/Project/"
    dir4 = "D:/Test/User/Project/"
    

    What is the problem here? Why do I get a wrong path with dir4, whereas dir4 is definitly a relative directory and not a file?
    Btw, the same happens using absoluteDir() to get a QDir Objekt.

    regards
    Oliver

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stvokr
      wrote on last edited by
      #2

      Additional Information: This works on linux as aspected.

      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