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. Currently Working Directory on Windows vs Mac OS X ...

Currently Working Directory on Windows vs Mac OS X ...

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 724 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.
  • T Offline
    T Offline
    tmason101
    wrote on last edited by
    #1

    Hello,

    On startup I would like to set my application's working directory to where the application's folder location is.

    So, the following works great on Windows:

    @
    QApplication a(argc, argv);
    QDir::setCurrent(QApplication::applicationDirPath());
    QTPrimaryApplicationWindow w;
    w.setWindowTitle("Ready to Process");
    w.resize(780, 480);
    QMessageBox::information(&w, QObject::tr("Current Directory"),
    QObject::tr("Current working directory is: ") + QApplication::applicationDirPath(), QMessageBox::Ok );
    @

    However, when I run this on a Mac what happens is that the application's working directory is two levels deeper in the "Contents/MacOS" folder.

    I would have to then do:

    @
    QDir::cdUp();
    QDir::cdUp();
    @

    To get where the "application" is alongside all of the other files, etc.

    Is there a better, cross-platform way to do what I want to do or is this the only way?

    Thank you!

    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