如何在 GTK Stack Switcher 中使用图像
How to use images in GTK Stack Switcher
我正在使用 C++ 和 gtkmm 编写应用程序。我在其中制作了一个 Gtk 堆栈。现在我想在 stackswitcher 的按钮上添加图像而不是文本。我认为这是可能的,因为在 gtk3-demo:
不幸的是,该示例是使用 UI 文件制作的,我想在没有 UI 设计器的情况下完成。现在我发现 this answer:
但对我帮助不大。答案是使用 stack.child_set_property
但我检查了堆栈的 gtkmm 文档,对于 C++ 没有这样的东西。最接近的匹配项是 Gtk::Stack::child_property_name
,注释为 returns A ChildPropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes
。我想这可能是我正在寻找的东西,但由于缺乏示例,我不知道如何使用它。
总结一下:谁能告诉我如何将图像设置为 StackSwitcher 的标签?
好的,看来我找到了答案。如果以后有人需要,我会post:
要将 Stack Switcher 的文本标签更改为图像,我只需要这样做:
stack->child_property_icon_name(ChildName) = "Icon Name";
我正在使用 C++ 和 gtkmm 编写应用程序。我在其中制作了一个 Gtk 堆栈。现在我想在 stackswitcher 的按钮上添加图像而不是文本。我认为这是可能的,因为在 gtk3-demo:
不幸的是,该示例是使用 UI 文件制作的,我想在没有 UI 设计器的情况下完成。现在我发现 this answer:
但对我帮助不大。答案是使用 stack.child_set_property
但我检查了堆栈的 gtkmm 文档,对于 C++ 没有这样的东西。最接近的匹配项是 Gtk::Stack::child_property_name
,注释为 returns A ChildPropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes
。我想这可能是我正在寻找的东西,但由于缺乏示例,我不知道如何使用它。
总结一下:谁能告诉我如何将图像设置为 StackSwitcher 的标签?
好的,看来我找到了答案。如果以后有人需要,我会post: 要将 Stack Switcher 的文本标签更改为图像,我只需要这样做:
stack->child_property_icon_name(ChildName) = "Icon Name";