当我在 Glade 中指定函数名称时,是否必须手动附加 gtk 信号处理程序?
我正在编写我的第一个 gtk 程序,使用 gtkmm 和glade。 我制作了一个文件选择器按钮,它有一个名为文件集的信号 所以我将其设置为我假设的函数名称,我希望它在选择文件时调用。 但后来我看到这里: http://library.gnome.org /devel/gtkmm-tutorial/unstable/sec-builder-accessing-widgets.html.en
他们手动获取对话框小部件并在代码中设置按钮信号处理程序。 哪种方法是正确的?
虽然我在这里提供任何优秀示例的链接都会很方便,但它们似乎很少而且相距甚远。谢谢。
I'm writing my first gtk program, using gtkmm, and glade.
I made a filechooserbutton and it has a signal called file-set
So I set that to what I assume is the function name I want it to call when the file is chosen.
But then I see here:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-builder-accessing-widgets.html.en
That they're manually getting the dialog widget and setting a button signal handler in the code.
Which is the right way to do it?
And while I'm here any links to good examples would be handy, they seem to be few and far between. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我就是这样做的:
编辑:
基本上,*this 是您将在其上调用信号处理程序函数的对象。
这就是我的 main 的样子:
MainWindow
基本上是一个包装 GtkWindow 并定义小部件的类,a.洛杉矶:希望这有帮助!
This is how I did it:
edit:
Basically the *this is the object on which you will be calling the function your signal handler.
This is what my main looks like:
MainWindow
is basically a class that wraps GtkWindow and defines the widgets, a. la.:Hope this helps!
我在另一个 stackoverflow 问题中事后找到了我的问题的答案。
但我不记得是哪一个了。
答案似乎是您必须以编程方式将信号处理程序添加到代码中的小部件中,gtkbuilder 不会为您做这件事。
I found the answer to my question as an afterthought in another stackoverflow question.
But I don't remember which one it was.
The answer seems to be that you have to programmatically add the signal handler to the widget in your code, the gtkbuilder won't do it for you.