Widgets
| Chapter 3. Basics |

## Widgets

gtkmm applications consist of windows containing widgets, such as buttons and text boxes. In some other systems, widgets are called "controls". For each widget in your application's windows, there is a C++ object in your application's code. So you just need to call a method of the widget's class to affect the visible widget.

Widgets are arranged inside container widgets such as frames and notebooks, in a hierarchy of widgets within widgets. Some of these container widgets, such as Gtk::VBox, are not visible - they exist only to arrange other widgets. Here is some example code that adds 2 Gtk::Button widgets to a Gtk::VBox container widgets:

    m_box.pack_start(m_Button1);
    m_box.pack_start(m_Button2);

and here is how to add the Gtk::VBox, containing those buttons, to a Gtk::Frame, which has a visible frame and title:

    m_frame.add(m_box);

Most of the chapters in this book deal with specific widgets. See the Container Widgets section for more details about adding widgets to container widgets.

Although you can specify the layout and appearance of windows and widgets with C++ code, you will probably find it more convenient to design your user interfaces with `Glade` and load them at runtime with `libglademm`. See the Glade and libglademm chapter.

Although gtkmm widget instances have lifetimes and scopes just like those of other C++ classes, gtkmm has an optional time-saving feature that you will see in some of the examples. `Gtk::manage()` allows you to say that a child widget is owned by the container into which you place it. This is allows you to `new()` the widget, add it to the container and forget about deleting it. You can learn more about gtkmm memory management techniques in the Memory Management chapter.

Chapter 3. Basics |  | Signals