(只是修改了后缀名而已,做一个伪装)
测试:
QFile file(QApplication::applicationDirPath() + "/config.dll");
qDebug()<<QApplication::applicationDirPath() + "/config.dll";
if (file.open(QIODevice::ReadOnly))
{
QByteArray ba = file.readAll();
file.close();
//读取全部信息
QJsonParseError json_error;
QJsonDocument jsonDoc(QJsonDocument::fromJson(ba, &json_error));
if (json_error.error == QJsonParseError::NoError)
{
QJsonObject rootObj = jsonDoc.object();
qDebug()<<rootObj.value("agree").toBool();
qDebug()<<rootObj.value("name").toString();
qDebug()<<rootObj.value("name1").toString();
}
}
else{
qDebug()<<"can not read!";
}
结果:
"D:/Qt/Qt5Book/Qt5.9Samp/test/test2/build-test-Desktop_Qt_5_9_1_MinGW_32bit-Debug/debug/config.dll"
true
"lpl"
"连xx"
可以!!!?