Results 1 to 5 of 5

Thread: Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

  1. #1
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

    Hi,

    I need an advice from someone who has an experience in deploying applications for both platforms: Windows and Mac OS X.
    The problem is that, in windows, all additional files such a local sort of database saved via QDataStream class, external binary resources (*.rcc), and translations (*.qm files) may be simply uploaded in the same directory and the application can find it. On the other hand, Mac OS X causes problems unless I provide absolute path. Unless I build all resources into an application, Mac cannot see them. I really need that run-time load mode available because the "database" file can be updated frequently.

    I read about Mac OS X that it uses a special folder called "bundle". This is like folder with special directories: Contents/, MacOS/, and Resources/ etc. I thought I could upload the local database to Resources/ but it does not work--Mac still cannot see it. Any idea where I should keep all extra files so that they can be found my iOS system?


    Thanks

    PS.I just thought I could use something that returns the application's path. It is somehow solution but I was wondering if there is a better one as well.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

    Why don't you put the database into "Resources" and use relative path (E.g. ../Resources/database.db)?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

    I am simply not familiar with file system of Mac OS X. I did not know that. Where does the "relative path" relate to? If I, for instance, use "file_name", in terms of bundle, where does it relate to?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

    The bundle it's just a special directory which have the following structure:
    myapp.app
    |----Contents
    |----MacOS
    |----myapp (this is the executable)
    |----Resources (optionally)
    ...
    (See Deploying an Application on Mac OS X.)
    QCoreApplication::applicationDirPath() returns the directory where an executable is located.
    So, putting this info together, you can get relative path to your database:
    Qt Code:
    1. ...
    2. QString path = "mydatabase.db";
    3. QString fullDatabasePath = QString::fromLatin1("%1/../Resources/%2")
    4. .arg(QCoreApplication::applicationDirPath(), path);
    5. ...
    To copy to clipboard, switch view to plain text mode 
    Something like this.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    ZikO (4th September 2012)

  6. #5
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Application for both Mac OS X and Windows. Windows OK. Mac OS X is not OK.

    Thanks. It's working

Similar Threads

  1. How to run Qt application from windows commandline?
    By aurora in forum Qt Programming
    Replies: 4
    Last Post: 26th April 2012, 09:36
  2. Replies: 3
    Last Post: 26th February 2012, 22:44
  3. Replies: 3
    Last Post: 12th July 2010, 06:25
  4. Application Plugins in Windows [XP]
    By dcurtis in forum Installation and Deployment
    Replies: 10
    Last Post: 9th February 2007, 03:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.