1

I have developed an application that I plan to deploy on Windows, Mac, and Linux. The program requires access to some files (scripts and the like) at run-time.

The installation process should install the files to a location that my application can later determine without user-intervention (or perhaps just a prompt allowing the user to change the location, if desired).

What is the best way to achieve this? I can't seem to find any way to:
1. Use a "standardized path" variable in the project file's INSTALLS statement. (e.g., my application could use QStandardPaths to initialize the location, but I can't figure out how to access this path from the INSTALLS statement)
2. Save the path to my project's QSettings (.plist, registry, whatever) for later retrieval

That leaves me with creating a custom project file and INSTALLS command for each environment, and then I still can't install to the user's directory because I don't know the user's name when I deploy the make command. It seems as if there must be a better way, but I can't seem to find any documentation for this. Am I just using the wrong keywords in my searches? Thanks in advance!

Lifewithsun
  • 968
  • 14
  • 34
Ken Vaughn
  • 23
  • 5
  • For example: Let's say I've developed a text editor (myeditor.app). When I distribute the program, I want to include a sample text file (readme.txt) that will automatically launch every time the user opens the app. Users are allowed to edit and save this file as desired, in my program or another. How do I distribute this extra file for a mac? Do I just add it to the DMG and let users install it wherever - and then prompt them for where they put it when I launch my app? Seems like there should be a better way. – Ken Vaughn Nov 12 '14 at 18:50
  • Actually, the final solution to my problem was found by downloading and configuring macinstallerapp (http://sourceforge.net/projects/macinstallerapp/files/) and ignoring the INSTALLS directive entirely – Ken Vaughn Nov 15 '14 at 00:02

2 Answers2

0

What standard directory? What type of getting that standard directory?

For instance, you can put such thing in your windows branch of .pro file:

win32 {
  APPDATA_DIR = $$system(echo %APPDATA%) # should be %LOCALAPPDATA% as requested
  message($$APPDATA_DIR)
}

Just unsure of what exact kind of standartized path you are talking about. QStandardPaths knows many. It makes sense to be more concrete to find the correspondence with concrete OS.

Also somewhat relative reply on mine, on how to check the correspondence with certain variable, etc: Qt .pro file - how to add conditioning on OSX version?

Community
  • 1
  • 1
Alexander V
  • 8,351
  • 4
  • 38
  • 47
  • GenericDataLocation is probably the most appropriate for what I am trying to do (i.e., "~/Library/Application Support", or "C:/Users//AppData/Local"). But how do I get this to work on all three platforms (Win, Mac, Linux)? – Ken Vaughn Nov 11 '14 at 20:31
  • http://stackoverflow.com/questions/11113974/what-is-the-cross-platform-way-of-obtaining-the-path-to-the-local-application-da – Alexander V Nov 11 '14 at 20:55
  • Are you suggesting that I can put Java code into the .pro file? I don't think this is allowed. Once again, I know how to find the directory in my application. What I don't know how to do is install my files to a known location prior to running my application. Mac seems to want to store everything in a Bundle in the .app file where it is hidden from the user, but I want my files visible. – Ken Vaughn Nov 12 '14 at 22:34
  • Nope, that piece of code shows that they use OS for getting that info. That can be somehow reused in .pro file. Just an example. And the point of handling these things in .pro file not in the app code is understood from the very beginning. – Alexander V Nov 12 '14 at 22:50
  • Nope, Qt gives me an error when I insert that code into my *.pro file – Ken Vaughn Nov 13 '14 at 00:01
  • The piece of code above? I tested it in my system with Qt Creator on Windows. – Alexander V Nov 13 '14 at 03:52
  • Okay, I finally got the above code to work and figured out that I could do the other platforms with an else statement. (i.e., win32 {...} else {...} And I can appear to use '~' to get into the users directory in either Mac or Linux. Thanks for the help. – Ken Vaughn Nov 13 '14 at 13:53
0

Maybe this class will help you

QStandardPaths documentation

But your problem is still little bit unclear for me.

QtRoS
  • 1,149
  • 1
  • 16
  • 23