GTK and C++


gtkmm is the official C++ interface for GTK. Highlights include typesafe callbacks, and a comprehensive set of widgets that are easily extensible via inheritance. You can create user interfaces in code using Gtk::Builder. There’s extensive documentation, including API reference and a tutorial.

gtkmm is free software distributed under the GNU Library General Public License (LGPL).


gtkmm follows the official GNOME Platform Bindings release schedule. This guarantees API/ABI-stability and new releases on a predictable schedule, delivering C++ API for the underlying GTK+ and GNOME APIs as soon as possible.


There is an official gtkmm API Documentation for using GTK and C++ together provided on the gtkmm website.

A Hello World app

// File: helloworld.h


#include <gtkmm/button.h>
#include <gtkmm/window.h>

class HelloWorld : public Gtk::Window

  virtual ~HelloWorld();

  //Signal handlers:
  void on_button_clicked();

  //Member widgets:
  Gtk::Button m_button;

// File:

#include "helloworld.h"
#include <iostream>

: m_button("Hello World")   // creates a new button with label "Hello World".
  // Sets the border width of the window.

  // When the button receives the "clicked" signal, it will call the
  // on_button_clicked() method defined below.

  // This packs the button into the Window (a container).

  // The final step is to display this newly created widget...;


void HelloWorld::on_button_clicked()
  std::cout << "Hello World" << std::endl;
// File:

#include "helloworld.h"
#include <gtkmm/application.h>

int main (int argc, char *argv[])
  auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

  HelloWorld helloworld;

  //Shows the window and returns when it is closed.
  return app->run(helloworld);


After compiling and run the above code and you should see get the below given output:

gtkmm output for a hello world application


This code depicts how to use GTK C++ binding for creating a simple Hello World application. A more detailed explanation of the above code can be checked out here.


You can find various useful tutorials regarding gtkmm from this source.


If you are interested in contributing to the gtkmm binding project, you can get a head start by reading the instructions on how to get started for contributing to gtkmm here.

If you want to get in touch with the original source files, you can visit the project’s git repository on Gitlab.

See More

Observed a typo or some missing information, edit this page.
Read on how to contribute to this website.