Constructor

#include <gtkmm/button.h>

Gtk::Button *btn = new Gtk::Button("label 1", true);

// rename label

btn->set_label("Rename~");

Image Button

Untitled

btn->add_pixlabel ("image_path.png", "button label");

Signals

The clicked event is deprecated in the new gtkmm version.

press & release:

Gtk::Widget::signal_pressed()
// sample
btn.signal_pressed().connect(sigc::mem_fun(*this, &functionPtrName));

// ----------------------------

Gtk::Widget::signal_release()
// sample
btn.signal_released().connect(signc::mem_fun(*this, &functionPtrName));

enter & leave:

// when the mouse pointer into the button
Gtk::Widget::signal_enter()
// sample
btn.signal_enter().connect(sigc::mem_fun(*this, &functionPtrName));

// when the mouse pointer leaves the button
Gtk::Widget::signal_leave()
// sample
btn.signal_leave().connect(sigc::mem_fun(*this, &functionPtrName));

Toggle Button(Check button)

#include <gtkmm/checkbutton.h>

...

Gtk::CheckButton btn;

...

btn.signal_toggled().connect(sigc::mem_fun(*this, &ClassName::FunctionName));

Cover the entire window (Simple Code)

Demo

Demo

#include <gtkmm.h>

int main(int argc, char* argv[]){
 Gtk::Main kit(argc, argv);

 Gtk::Window window;
 Gtk::Button btn ("Click me");
 window.set_default_size(800, 600);
 window.set_title("Gtkmm Title Name");

 btn.show();
 window.add(button);

 Gtk::Main::run(window);

 return 0;
}

simple code (pointer object)

#include <gtkmm.h>

int main(int argc, char *argv[])
{
  auto app = Gtk::Application::create(argc, argv, "copyright");

  Gtk::Window window;
  window.set_default_size(200, 200);

  Gtk::Button *btn = new Gtk::Button ("click me!");
  btn->show();
  window.add(*btn);

  return app->run(window);
}

Press the button to send a signal

Sample: