Replies: 5 comments 48 replies
-
应为: enum class FuncPages
{
//...
};
//...
...snip...FuncPages current_func_page = FuncPages::xxxx |
Beta Was this translation helpful? Give feedback.
-
main.cpp |
Beta Was this translation helpful? Give feedback.
-
我终究没搞懂你的代码什么意思,毕竟我没用过Qt吧。 最好全部重构 要么,你把整个设计流程说一遍??? |
Beta Was this translation helpful? Give feedback.
-
这一段直接用
bool ConfigManager::loadConfig()
{
QFile configFile;
configFile.setFileName(configFileName);
if (!configFile.open(QIODevice::ReadOnly) || configFile.size() >= 0x100000)
return false;
QString text_oriConfig = configFile.readAll();
configFile.close();
QString text_configHeader;
QRegularExpression regExp;
if (!bText_between(&text_configHeader, &text_oriConfig, "<manifest>", "</manifest>"))
return false;
regExp.setPattern("(?<=\\[for=)\\S*(?=\\])");
if (regExp.match(text_configHeader).captured() != PROGRAMTEXTID)//配置与程序不符
return false;
regExp.setPattern("(?<=\\[createrVersion=)\\S*(?=\\])");
if (regExp.match(text_oriConfig).captured().toUShort() != PROGRAMBUILDVER)//配置与版本不符//TODO此处限制了唯一版本,应有版本兼容性
return false;
QString text_configData;
if(!bText_between(&text_configData,&text_oriConfig, "<data>", "</data>"))
regExp.setPattern("(?<=\\[eptBlocks=)\\S*(?=\\])");
QJsonDocument data_jsonDoc;
QJsonParseError data_jsonError;
data_jsonDoc.fromJson(text_configData.toStdString().c_str(), &data_jsonError);
if (data_jsonError.error != QJsonParseError::NoError)
return false;
//开始解析键值
QJsonObject obj_main;//配置根(/)
QJsonObject obj_onlineSearchEngines = obj_main.value("OnlineSearchEngines").toObject();
QJsonObject obj_localCollectorEngines = obj_main.value("LocalCollectorEngines").toObject();
QJsonObject obj_workflowEngines = obj_main.value("WorkflowEngines").toObject();
QJsonObject obj_working = obj_main.value("Working").toObject();
QJsonObject obj_display = obj_main.value("Display").toObject();
configs.display.styleSheetFileName = obj_display.value("StyleSheet.Filename").toString();
return true;
} |
Beta Was this translation helpful? Give feedback.
-
中肯的。如果你给出具体可行的建议,我会尝试去接受。( ̄▽ ̄) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions