-1

The docs say this should work:

bool did=pixmap.save( "hoppy.png" );

qDebug("did is: %d",did);

My logging returns 1 suggesting, as per docs, that the save was successful. However, no file appears on my drive. According to the docs, this save() should indeed save a file, so what is missing?

László Papp
  • 51,870
  • 39
  • 111
  • 135
johnbakers
  • 24,158
  • 24
  • 130
  • 258
  • 4
    Are you 100% sure you're looking in the right directory? Specify a full path to be sure. – Mat Sep 28 '13 at 16:28
  • Use windows search, spotlight or locate (depending on your platform) to find the file. It's there. It's not where you're looking for it. – Kuba hasn't forgotten Monica Sep 29 '13 at 01:15
  • @Mat i'm curious, wouldn't it just dump it in the actual directory of the executable? I also did a full search on my Mac using spotlight and cannot find it – johnbakers Sep 29 '13 at 03:32
  • It will write it in whatever the current directory is when that code runs. Could be where the executable is, or anywhere else. – Mat Sep 29 '13 at 03:34
  • @Mat on Mac I tried to specify something like `~/filename.png` with then the `save()` returned false. – johnbakers Sep 29 '13 at 03:39
  • `~`-expansion is something your shell does, not the operating system itself. Use a full path. – Mat Sep 29 '13 at 03:40
  • @Mat using full path worked, thanks. feel free to make it an answer and i'll accept it. – johnbakers Sep 29 '13 at 04:46

2 Answers2

0

Another answer notes:

Nothing missing; it is simply saved to the folder of where you run the qt executable from

However my question indicated that this is actually not the case here.

Using the full path rather than a relative path or instead of using the ~ character, resolved it.

johnbakers
  • 24,158
  • 24
  • 130
  • 258
0

According to the docs, this save() should indeed save a file, so what is missing?

Nothing missing; it is simply saved to the folder of where you run the qt executable from. If it is a direct invocation, then it is beside the executable, otherwise it is beside the script or other program that calls the qt executable (sure, the other program could modify the current working directory, but let us forget about that for a bit).

If that is not what you would like to do, you better use an absolute path to the location where you wish to save it. However, if it is some common location, consider using QStandardPaths.

László Papp
  • 51,870
  • 39
  • 111
  • 135
  • The phrase "it is simply saved to the folder of where you run the qt executable from" is incorrect in this case, though it is a decent idea, I am removing this is the selected answer. My question made it clear that such behavior was not happening in this case as no file appeared anywhere on the system. – johnbakers Oct 07 '13 at 06:39
  • And, I thank you sir, in your response, by downvoting my question. I am glad there are great users like yourself who value reputation scores more than quality reasoning. – johnbakers May 07 '14 at 05:00
  • thank you for deleting your unnecessary comments. That helps make the site higher-quality. May I recommend in the future that you focus less on little details surrounding the vote on one of your answers, and focus more on the quality of the answers. – johnbakers May 07 '14 at 10:34