Error en Gtk :: Builder get_widget () prog más simple

Este es mi programa:

#include <gtkmm.h>

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

Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_file("");

Gtk::Window win;
builder->get_widget("winobj", win);


I use this command in terminal to compile it, as I use for any other GTK+ program I can correctly compile:

g++ myprog.cpp -o myprog `dpkg-config --cflags --libs gtkmm-3.0`

Y me sale este error:

builder_0.cpp: In function ‘int main(int, char**)’:
builder_0.cpp:10:35: error: no matching function for call to ‘Gtk::Builder::get_widget(const char [7], Gtk::Window&)’
builder_0.cpp:10:35: note: candidate is:
/usr/include/gtkmm-3.0/gtkmm/builder.h:435:8: note: template<class T_Widget> void    Gtk::Builder::get_widget(const Glib::ustring&, T_Widget*&)

I tried many twiddles, defining win as pointer, converting the string literal to Glib::ustring, ..., but didn't work. Appreciating helps! :-)

preguntado el 30 de enero de 12 a las 19:01

What error did you get when you defined win as pointer? -

1 Respuestas

The message is very clear to me. T_Widget*& means, that you have to pass a (reference to a ) pointer. I changed your code to this:

Gtk::Window *win;
builder->get_widget("winobj", win);

Now it should work as expected.

Respondido el 30 de enero de 12 a las 23:01

OMG! It works! And I can't believe my failure all these times was forgetting the dereferencing in run() and I ignorantly didn't even notice! Thanks so much for your help ipc :-) - Haix64

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.