문제

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?

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top