问题描述
Qt manu说在使用qUtf8Printable()
的语句之后,char指针将无效。这是因为QString::toUtf8()
返回的数组将超出范围。
那么qUtf8Printable(key)
会在调用qWarning("%s",Utf8Printable(key));
时超出范围吗?
解决方法
这很安全。用作参数的临时值将保留到函数调用结束。
Qt manu说在使用qUtf8Printable()
的语句之后,char指针将无效。这是因为QString::toUtf8()
返回的数组将超出范围。
那么qUtf8Printable(key)
会在调用qWarning("%s",Utf8Printable(key));
时超出范围吗?
这很安全。用作参数的临时值将保留到函数调用结束。