Question

I want to add another Box to my window in the Gtk example, so that I can put other elements below menu.

Here is the link to example:

12.4.1. Main Menu example

I have searched for it, but found HBox/Vbox, but in the example, there is Box declared, with Gtk::ORIENTATION_VERTICAL

How do I add a simple element like lable or button below the menu?

Was it helpful?

Solution

You already have a Box whose Orientation is set to Vertical and you can easily add other elements like buttons and labels to it. So add a button below the menubar as following:

Gtk::Widget* pMenubar = m_refUIManager->get_widget("/MenuBar");
if(pMenubar)
    m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK);

Gtk::Button* pButton = new Gtk::Button(Gtk::Stock::OK);
m_Box.pack_start(*pButton, Gtk::PACK_SHRINK);

show_all_children();

P.S: For a better visualization I'd recommend using Glade to see how it should look, what should go where, how packing is done. And then you can easily do the same in your C++ code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top