I am trying to get the relative path from files that I would like to write. Here a situation:
I save a conf file in D:\confs\conf.txt
. I have in my programs some files read from D:\images\image.bmp
. In my conf.txt
I would like to have ../images/image.bmp
.
I see some useful classes like QDir
or QFileInfo
but I don't know what it's the best to use. I tried:
QDir dir("D:/confs");
dir.filePath(D:/images/image.bmp) // Just return the absolute path of image.bmp
I read the doc and it says filePath
only work with files in the dir set (here D:\confs
) but I wonder if there is a way to indicate to search from a different dir and get his relative path.