0

How can I put Gtk:Grid in Gtk:Window using gtkmm. It says "no known conversion for argument 1 from «Gtk::Grid()» to «Gtk::Widget&»" when I'm trying to call main_win.add(grid); This works but it's too ugly:

...
int main (int argc, char *argv[])
{

Main kit(argc, argv);

Label label1("Hello1",0,0.5);
Label label2("Hello2",0,0.5);

Grid grid;

(*((Container*)&grid)).add(label1);
(*((Container*)&grid)).add(label2);

Window main_win(Gtk::WINDOW_TOPLEVEL);
main_win.add(*((Widget*)&grid));

main_win.show_all();

kit.run(main_win);

return 0;
}
user28667
  • 1,073
  • 10
  • 9

2 Answers2

1

You don't need any of those crazy casts.

Grid grid
Window window;
window.add(grid)

will work just fine.

murrayc
  • 2,103
  • 4
  • 17
  • 32
0

Hm... Now it works... I think I did nothing... I'm not sure but it looks like Grid grid(); was in my source code because it causes the same error.

user28667
  • 1,073
  • 10
  • 9
  • 1
    This is an example of C++'s "most vexing parse", see http://stackoverflow.com/q/1424510/240633 – ergosys Jul 29 '12 at 21:31