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. QFileInfo : set relative path for a file in current directory.

QFileInfo : set relative path for a file in current directory.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 767 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
    samdol
    wrote on last edited by
    #1

    Hi,
    How can I set relative path of a file in current directory to QFileInfo?
    I tried like
    QFileInfo qfi("./"+filename);
    But it did not work.

    jsulmJ 1 Reply Last reply
    0
    • S samdol

      Hi,
      How can I set relative path of a file in current directory to QFileInfo?
      I tried like
      QFileInfo qfi("./"+filename);
      But it did not work.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @samdol

      QFileInfo qfi(filename);
      

      should work.

      Are you sure current directory is the one you assume it should be?
      Check it with http://doc.qt.io/qt-5.7/qdir.html#currentPath

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      3
      • jsulmJ jsulm

        @samdol

        QFileInfo qfi(filename);
        

        should work.

        Are you sure current directory is the one you assume it should be?
        Check it with http://doc.qt.io/qt-5.7/qdir.html#currentPath

        S Offline
        S Offline
        samdol
        wrote on last edited by
        #3

        @jsulm
        Thank you. You are right. I misunderstand the currentPath. Because I did not set it manually, currentPath was the path where my executable exists.

        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