0

这是我的代码,我在选择带有小部件的文件后尝试获取 file_nameFileChooserButton

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()
            )
    );
}

我调用functinoget_filenameget_filename返回空字符串“”;

4

1 回答 1

1

在连接时计算的信号和sigc::bind传递值。所以当你这样做时

chooserButton->get_filename()

这将返回一个空字符串,此时Gtk::FileChooserButton尚未显示或使用。

您需要调用chooserButton->get_filename()回调函数来获取当前值。

于 2016-10-22T10:07:21.710 回答