The documentation for HBox
and VBox
includes the statement:
Deprecated: Use Box instead, which is a very quick and easy change. But we recommend switching to Grid, since Box will go away eventually.
However, it isn't obvious what the "quick and easy change" should be.
How do you use Box
and/or Grid
to achieve the functionality of VBox
or HBox
?
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.
来源:https://stackoverflow.com/questions/19532619/how-do-you-replace-hbox-vbox-with-box-grid