cbutton is of type ‘GtkWidget*’, so Glib::wrap() is returning a Gtk::Widget*. If you give Glib::wrap() a GtkButton* you should get a Gtk::Button* out. So you can:
Gtk::Button *m_button = Glib::wrap(GTK_BUTTON(cbutton));
// or
Gtk::Widget *m_button = Glib::wrap(cbutton);
// or
Gtk::Button *m_button = static_cast<Gtk::Button*>(Glib::wrap(cbutton));
If you are migrating to gtkmm, why do you call gtk functions which have
gtkmm equivalents? What’s wrong with this?
#include<gtkmm.h>
#include<iostream>
class example : public Gtk::Window
{
public:
example();
~example();
Gtk::Button m_button;
};
example::example()
{
set_default_size(200,200);
m_button.set_label("hello world");
add(*m_button);
std::cout << m_button->get_label() << '\n';
}
It looks like you’re using gtkmm3. Gtkmm4 is recommended in new code, unless you
have a good reason to use gtkmm3. If you use gtkmm4, change your main() function.
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("exemple.org");
return app->make_window_and_run<example>(argc, argv);
This was just an example.
The program I intend to port is a Geany IDE plugin.
And to access certain parts of the IDE’s main window, I need to get the widgets that are in it and were created in Gtk+3.0