gpt4 book ai didi

从 glade 克隆一个 GtkWidget,这样它就可以在应用程序中多次重用

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:56 26 4
gpt4 key购买 nike

我正在用 C 编写 Gtk+3 应用程序。

用户界面是用 glade 构建的。

我创建了一个独立的 GtkBox,它应该在我的应用程序的多个地方使用。当我尝试多次使用 GtkBox 时,出现以下错误:

(tuxmusicstudio:27491): Gtk-WARNING **: Attempting to add a widget with type GtkBox to a container of type GtkBox, but the widget is already inside a container of type GtkBox, please use gtk_widget_reparent()

我如何克隆 GtkWidget 以便它可以一次又一次地重复使用?

最佳答案

您不能像这样克隆一个小部件。要么将您的可重用小部件放入其自己的 Glade 文件中,然后使用 GtkBuilder 多次加载它;或为您想要的小部件创建一个类并多次实例化它。

关于从 glade 克隆一个 GtkWidget,这样它就可以在应用程序中多次重用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22584193/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com