clone a GtkWidget from glade so it will be reusable several times in application

微笑、不失礼 提交于 2020-01-04 15:28:20

问题


I'm writing a Gtk+3 application in C.

The user interface is built with glade.

I created an independent GtkBox that should be used in several places in my application. When I try to use that GtkBox more then once I get the following error:

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

How can I clone the GtkWidget so it will be reusable again and again?


回答1:


You can't clone a widget as such. Either put your reusable widget into its own Glade file and load it more than once using GtkBuilder; or create a class for the widget you want and instantiate it more than once.



来源:https://stackoverflow.com/questions/22584193/clone-a-gtkwidget-from-glade-so-it-will-be-reusable-several-times-in-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!