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. [Solved]how to get special path in mac
Forum Updated to NodeBB v4.3 + New Features

[Solved]how to get special path in mac

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.2k 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.
  • S Offline
    S Offline
    szuzsq
    wrote on 11 Oct 2011, 09:26 last edited by
    #1

    I was a windows programmer, and right now begin to developer under mac.

    1).How to judge a file or directory is exist.
    when I call c function:
    return access(fn,0)==0;
    when the file or directory is exist, it return true.
    but how to differ it really a file or directory?


    2).How to get current app path.
    for example:
    /Users/mike/Qt/Qt Creator.app/Contents/MacOS/Qt Creator


    3).How to get current user's document path.
    for example:
    /Users/szuzsq/Documents/

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on 11 Oct 2011, 09:50 last edited by
      #2
      1. @QFileInfo::isDir()@
      2. @QCoreApplication::instance()->applicationFilePath()@
      3. @QDir::homePath()@ for home dir, but I think not way get documents dir with Qt.

      --
      Vasiliy

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on 11 Oct 2011, 09:51 last edited by
        #3

        Well, I suggest you just use the Qt API instead of the C API.

        • "QFile::exists()":http://doc.qt.nokia.com/latest/qfile.html#exists-2
        • "QDir::currentPath()":http://doc.qt.nokia.com/latest/qdir.html#currentPath / "QCoreApplication::applicationFilePath()":http://doc.qt.nokia.com/latest/qcoreapplication.html#applicationFilePath
        • "QDir::homePath()":http://doc.qt.nokia.com/latest/qdir.html#homePath / "QDesktopServices::storageLocation()":http://doc.qt.nokia.com/latest/qdesktopservices.html#storageLocation
        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on 11 Oct 2011, 09:56 last edited by
          #4

          @Lucas QDesktopServices::storageLocation() is good point, I'm totally forgot about this. :)

          --
          Vasiliy

          1 Reply Last reply
          0

          1/4

          11 Oct 2011, 09:26

          • Login

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