问题描述
Gtk +中有一种方法可以将一个小部件堆叠在另一个小部件上 - 不包括GtkFixed? GtkFixed不能正常工作,原因有两个:1)我需要Z顺序,2)我需要一个小部件来伸展并填充提供的空间。 / div>
我认为标准GTK中没有适当的容器。我将继承Gtk :: Fixed ...它仍然是最接近的一个,如果你使用gtkmm,那么子类化不应该很困难¹。然后,您可以控制所有窗口小部件的尺寸,并拉伸一个选定的孩子以填充空间。
要控制Z轴,您可能需要操作窗口小部件的X窗口 - 检查GDK有关GDK windows2主题的文档。我记得在PyGTK中每个部件都有gtk.Widget.window属性,我想对gtkmm也是一样。这假定你的所有子窗口小部件都有X窗口,所以f.e.你需要在Gtk :: EventBox中包装Gtk :: Label。
¹
²
Is there a way in Gtk+ to stack one widget on top of another -- not counting GtkFixed? GtkFixed doesn't work well for two reasons: 1) I need Z order, and 2) I need one widget to stretch and fill provided space.
I don't think there is a proper container in standard GTK. I would subclass Gtk::Fixed... it is still the closest one you can get, and if you use gtkmm then subclassing shouldn't be very difficult¹. Then you can control the dimensions of all widgets, stretching one selected child to fill space.
To control Z-axis you will probably need to manipulate widget's X windows--check GDK documentation on topic of GDK windows². I remember that in PyGTK each widget has gtk.Widget.window property, I guess that the same is for gtkmm. This assumes that all your child widgets have X windows, so f.e. you'll need to wrap Gtk::Label inside Gtk::EventBox.
¹ http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/chapter-customwidgets.html
这篇关于在Gtk +中堆叠小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!