tags:

views:

14

answers:

1

I have a Gtk::HBox which should contain two elements only. However, the constructor new Gtk::HBox() creates a box with three elements, so when I display my window, there is an ugly space where Gtk expects me to put a third element.

I thought the Gtk api would provide an easy way to set the number of children, but it doesn't. Since Glade allows me to create an HBox with two elements, I guess it can be done, but now I need to do it with c++ code.

It's very strange that I can't find answers in Google for such a simple question, I must be missing something... any ideas?

A: 

You should pass true in the expand and fill arguments to Gtk::Box::pack_start():

hbox.pack_start(child, true, true);

Or call its simpler override:

hbox.pack_start(child);
Frédéric Hamidi