读取 test.ini文件中的内容 ip和端口。
[assetServer]
ServerIp=10.10.100.185
ServerPort=1687
该文件在运行目录下
方法:
void getServerInfo(QString& strIP, int& port)
{
auto path = QApplication::applicationDirPath() + QStringLiteral("/NetConfig.ini");
if (!QFile::exists(path))
{
SPDLOG_ERROR("can not open {}", path.toLocal8Bit().constData());
}
QSettings cSet(path, QSettings::IniFormat);
cSet.setIniCodec("UTF8");
cSet.beginGroup("assetServer");
strIP = cSet.value("ServerIp").toString();
port = cSet.value("ServerPort").toInt();
cSet.endGroup();
}