保存配置 QSettings setting("config.ini",QSettings::IniFormat); setting.beginGroup("para"); setting.setValue("database","test"); setting.setValue("hostName","localhost"); setting.setValue("userName","root"); setting.setValue("port",3306); setting.setValue("password","123456"); setting.endGroup(); 读取配置 QSettings setting(":/config.ini",QSettings::IniFormat);setting.beginGroup("para");QString dataBaseName = setting.value("database").toString();QString hostName = setting.value("hostName").toString();QString userName = setting.value("userName").toString();int port=setting.value("port").toInt();QString passWord=setting.value("password").toString();setting.endGroup();