Domanda

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?

È stato utile?

Soluzione 2

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top