The Qt manu said The char pointer will be invalid after the statement in which qUtf8Printable()
is used. This is because the array returned by QString::toUtf8()
will fall out of scope.
So does qUtf8Printable(key)
will fall out of scope when call qWarning("%s", Utf8Printable(key));
?
This is safe. Temporary values used as argument survive until the end of the function call.