Frage

I want to save a QImage in the user's home, I use ~/ but save() seems to not appreciate and return false without any message... So

img->save("~/pict.jpg");

is not working and I'm looking for a glitch...

War es hilfreich?

Lösung

~ is interpreted by the Shell, not by the operating system (or the C library, or the Qt library).

You need to get the user's home directory through getenv("HOME"), for instance. See also How can I find the user's home dir in a cross platform manner, using C++?

With Qt, you can use QDir::homepath to retrieve the user's home directory in a platform independent way.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top