Re: Something simple I can't do



Strange! When I add

#if 0
  cmdOne->property_expand() = true;
  cmdTwo->property_expand() = true;
  cmdThree->property_expand() = true;
#else
  cmdOne->set_hexpand(true);
  cmdOne->set_vexpand(true);
  cmdTwo->set_hexpand(true);
  cmdTwo->set_vexpand(true);
  cmdThree->set_hexpand(true);
  cmdThree->set_vexpand(true);
#endif

the buttons fill all of the window when it's resized. And it works both with "#if 0" and "#if 1", and both with
  grdMain.attach (*cmdOne, 1, 1, 1, 1);
and
  grdMain.attach (*cmdOne, 0, 0, 1, 1);

Kjell

2012-02-05 18:57, yasser greyeb skrev:
Hi,
I'm haven't been able to make the widgets contained in a Gtk::Grid adjust their size and spacing when the Grid's size change. I read it is a matter of widgets' expand and margin property and yet I can't make it work. When the Grid is resized a blank space appears where I want widgets to be.
I have this code:
Gtk::Main kit(argc, argv);

Gtk::Window* main_win = new Gtk::Window (Gtk::WINDOW_TOPLEVEL);
main_win->set_title ("example");

Gtk::Grid grdMain;
Gtk::Button* cmdOne = new Gtk::Button("1", true);
Gtk::Button* cmdTwo = new Gtk::Button("2", true);
Gtk::Button* cmdThree = new Gtk::Button("3", true);

grdMain.attach (*cmdOne, 1, 1, 1, 1);
grdMain.attach_next_to (*cmdTwo, *cmdOne, Gtk::POS_BOTTOM, 1, 1);
grdMain.attach_next_to (*cmdThree, *cmdOne, Gtk::POS_RIGHT, 1, 2);

main_win->add(grdMain);
main_win->show_all_children ();

kit.run(*main_win);

I've tried changing property_margin and property_expand for all the button inside the Grid but doing it hasn't solved anything.

What I want is the Buttons to fill all the space inside the window. Thank you for your help.
Btw, sorry for my english, I speak spanish very well :P




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]