How do you replace HBox/VBox with Box/Grid

夙愿已清 提交于 2019-12-08 13:37:37

One of the big changes in gtkmm3:

Gtk::Box, Gtk::ButtonBox, Gtk::IconView, Gtk::Paned, Gtk::ProgressBar, Gtk::ScaleButton, Gtk::ScrollBar and Gtk::Separator now derive from Gtk::Orientable, allowing their orientation (vertical or horizontal) to be specified without requiring the use of a derived class such as Gtk::HBox.

Although Grid isn't mentioned above, both containers now have a method set_orientation; Box can also take it in the constructor. So for Box, set the orientation and use your usual pack_start, pack_end.

With Grid, if you scrutinize the documentation, you'll see this line:

Grid can be used like a Box by just using Gtk::Container::add(), which will place children next to each other in the direction determined by the orientation property.

So, it should be as simple as setting the orientation and then add your child widgets.

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