开发者

Glade: How do I pass more than one argument to a signal handler?

Glade: How do I pass more tha开发者_JAVA百科n one argument to a signal handler?


What you can do in glade is very limited. You can pass zero or one object as userdata to a signal handler. The object has to be a widget (or other object) also present in the glade project.

If you connect the signal from code on the other hand, you can pass a structure containing various stuff as you please.

And if you create signals yourself you can utilize marshallers to create how many arguments you want (for the signal handler prototype), but still just one userdata argument. So this will not let you specify more argument then connecting the signal, only then invoking it.


from here:

http://library.gnome.org/devel/gtkmm-tutorial/2.21/sec-connecting-signal-handlers.html.en ...

We just told you that the button's clicked signal is expecting to call a method with no arguments. All signals have requirements like this - you can't hook a function with two arguments to a signal expecting none (unless you use an adapter, such as sigc::bind(), of course). Therefore, it's important to know what type of signal handler you'll be expected to connect to a given signal.


Why don't you just simply obtain a reference to each of the objects that you need to access in the Event Handler when the application loads? If you store these references as global variables, then it wouldn't matter how many parameters you need to pass to the event handler. All of the Gtk Widgets would be available within your function to use however you see fit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜