void QtAESEncryptionAndDecryption::QStr2Char(const QString qstr, char* newChar)
{
if (qstr.length() > 1024 * 1024)
{
qDebug("QString长度超出栈大小(1MB)\n");
QMessageBox::warning(this, tr("Warning"), tr("The input-text is too large!"), QMessageBox::Yes);
return;
}
/*
QByteArray barray = qstr.toLatin1();
newChar = (char*)malloc(qstr.length());
strcpy(newChar,barray.data());
*/
std::string str = qstr.toStdString();
const char* ch = str.c_str();
if (sizeof(newChar) < sizeof(ch))
{
newChar = new char[qstr.length()];
memset(newChar, 0, sizeof(newChar) * 4 - 1);
}
strcpy(newChar, ch);
}
将QString 对象转换为 char*
最新推荐文章于 2024-09-16 22:36:39 发布