[Development] QStandardPaths could be helpful for cross platform portability, Qt Everywhere

Thiago Macieira thiago.macieira at intel.com
Tue Feb 24 19:02:23 CET 2015


On Monday 23 February 2015 23:24:07 Jeremy Whiting wrote:
> A second solution is to add some API to QStandardPaths to modify the paths
> at run time. This would allow libraries to add paths to QStandardPaths'
> standard paths that it needs in its initialization methods. For example a
> library that requires data files that it knows are installed to /some/path
> can add /some/path to the GenericDataLocation via something like
> QStandardPaths::addCustomPath(GenericDataLocation, "/some/path") and it's
> subsequent calls to QStandardPaths::locate(GenericDataLocation,
> "somedatafile") would get the file required.

Hi Jeremy

Thanks for the write up, it's appreciated.

I'm wondering if the above should be a global config or if we should make 
QStandardPaths support creating an object that a library could use internally. 
If we choose the latter, a library could set up its own, private search paths 
and not bother anyone else.

> Another similar option would be to always add relative paths based on the
> application binary or library (or both) so libraries installed inside a
> .app bundle on OS X could find the data files that are also inside the .app
> bundle. This way binaries on Windows could also find data files and
> libraries relative to the installation path of the executable itself, so if
> end users install MyProgram into D:\Some\Path\Myprogram, and the installer
> puts the data files beneath that, QStandardPaths api could find the data
> files wanted.

Indeed, we need that. For Qt itself, we have QLibraryInfo, but the 
installation prefix is usually hardcoded. For Mac, Linux and Windows, I think 
we have good solutions for determining the installation path of a library 
given a pointer located inside it, so we should really investigate relocatable 
builds and adapt both QLibraryInfo and QStandardPaths.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list