【发布时间】:2017-04-30 15:48:17
【问题描述】:
我正在尝试通过 C++ 程序编辑 gsetting。
我读过这个question 并且我能够获得价值。如果我尝试设置它(使用set_uint 方法),似乎进行了更改(如果我重新读取它会显示新值)但是,如果我手动检查,情况并非如此。我必须应用编辑吗?或者还有什么?
示例代码:
#include <giomm/settings.h>
#include <iostream>
int main() {
Glib::RefPtr<Gio::Settings> colorSetting =
Gio::Settings::create("org.gnome.settings-daemon.plugins.color");
Glib::ustring tempKey = "night-light-temperature";
//Works!
cout<<colorSetting->get_uint(tempKey)<<endl;
//Seems to work
colorSetting->set_uint(tempKey, (unsigned) 2300);
//Reads new value correctly
cout<<colorSetting->get_uint(tempKey)<<endl;
return 0;
}
提前致谢。
【问题讨论】:
-
显示代码 - 我们不是心灵感应的。 MVCE 最好。
-
@tambre 抱歉,现在添加!
-
好多了,干得好。
-
@tambre 有一个 MCVE 的魔术标签,
[MCVE],结果是:minimal reproducible example -
@Jonas 谢谢!我没有意识到这一点。一直以来,我一直在手动链接 minimal reproducible example 页面。
标签: c++ glib gnome gio gsettings