PDA

View Full Version : Filename -> directory



Persoontje
2nd December 2009, 21:57
Hi,

Hopefully the last question, and then my raytracer project will be finished ;-).

I save my raytracing files. After that, my program has to load some textures, models and so on. Now you have to specify the full path of the file you want to load.

I store the filename of the .ray file (where the program saves the scene in) in mFileName. It would be handy to extract the directory from the filename, so I could use that with QDir. Then the user could specify a 'relative path' to the file when they want to load a image, and they don't have to type the whole path.

So they could enter: testmodel.obj instead of c:\\files\\test\\test.obj (when the scene file is also stored in c:\\files\\test)

Is there a function in QT to do this? Or do I have to extract that manually using regexps or something like that?

schnitzel
2nd December 2009, 22:10
Look at QFileInfo.

Persoontje
2nd December 2009, 22:54
Thanks ;-)

I thought there was such a class, I just didn't no which ;-)