[gtkmm] Reducing the rows / columns of a Gtk::Table



i am trying to figure out the correct way to remove rows and columns from a Gtk::Table.

this doesn't work:

#include <gtkmm.h>
#include <iostream>
#include <vector>


using namespace Gtk;
using namespace std;

int main(int argc, char** argv)
{
  // The gtk context (event loop et al) in which this example will run.
  Main kit(argc, argv);

  Window w;
  Button *b1 = manage(new Button("One"));
  Button *b2 = manage(new Button("Two"));
  Table t;
  t.resize(1, 2);  // works
  t.attach(*b1, 0, 1, 0, 1);
  t.attach(*b2, 1, 2, 0, 1);
  t.resize(1,1);  // doesn't work

  w.add(t);
  w.show_all();

  kit.run();
}


this works:
#include <gtkmm.h>
#include <iostream>
#include <vector>


using namespace Gtk;
using namespace std;

int main(int argc, char** argv)
{
  // The gtk context (event loop et al) in which this example will run.
  Main kit(argc, argv);

  Window w;
  Button *b1 = new Button("One");
  Button *b2 = new Button("Two");
  Table t;
  t.resize(1, 2);  // works
  t.attach(*b1, 0, 1, 0, 1);
  t.attach(*b2, 1, 2, 0, 1);

  delete b2;  // necessary to make resize work
  t.resize(1,1);  // works now

  w.add(t);
  w.show_all();

  kit.run();
}

i suspect though, that this is not the intended way to use the table. i would certainly prefer to let manage work its wonders, and not worry about the memory for the widgets i attach in the table? is there a way to both use manage and be able to remove rows and columns from the table?

thanks!
-tim




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