这是我的代码,我在选择带有小部件FileChooserButton
Gtk::FileChooserButton *chooserButton = nullptr;
std::string idChooserButton = commonArray[b]["id"];
builder->get_widget(idChooserButton, chooserButton);
Php::call("var_dump",chooserButton);
if (strcmp(commonArray[b]["action"], "click") == 0) {
Php::Value callback = commonArray[b]["callback"];
chooserButton->signal_selection_changed().connect(
sigc::bind<Php::Value,Php::Value>(
sigc::mem_fun(*this, &ParserGtk::callbacks),
callback,
chooserButton->get_filename()
)
);
}
我打电话给functino get_filename
,但get_filename
返回空字符串“”;
答案 0 :(得分:1)
在连接时计算的信号和sigc::bind
传递值。所以当你这样做时
chooserButton->get_filename()
这将返回一个空字符串,Gtk::FileChooserButton
尚未在该点显示或使用。
您需要在回叫函数中调用chooserButton->get_filename()
以获取当前值。