Re: [gtkmm] Widgets within Notebooks (solved)



You can't add a widget to two containers at the same time, but you're doing that with Mainbox here. If you want Mainbox and its contents to be on a notebook page, you need to add it only to the notebook page and not to anywhere else.

Yes, you are right. My packing was wrong. This is how it works:


void ConstraintGui::showGui()
{
  std::cout << "START ConstraintGui::showGui()" << std::endl;

  // Create boxes and widgets on main window
  Gtk::VBox       *VBoxLeft   = manage(new Gtk::VBox (false, 2));
  Gtk::VBox       *VBoxRight  = manage(new Gtk::VBox (false, 2));
  Gtk::VBox       *MainBox    = manage(new Gtk::VBox (false, 2));
  Gtk::HBox       *HWidgetBox = manage(new Gtk::HBox (false, 2));
  Gtk::HButtonBox *ButtonBox  = new Gtk::HButtonBox();
  Gtk::Notebook   *Notebook   = new Gtk::Notebook();
  Gtk::Button     *QButton    = new Gtk::Button("Quit");

  // Add MainBox to the main window container
  add(*MainBox);

  // Add Tree Browser to VBoxLeft
  // More widgets for VBoxLeft will come ...
  VBoxLeft->pack_start(m_TreeBrowserBox);

  // Add Table to VBoxRight
  // More widgets for VBoxRight will come ...
  VBoxRight->pack_start(m_TableBox);

  // Add the Notebook and the Quit button to the MainBox
  Notebook->set_border_width(10);
  MainBox->pack_start(*Notebook);
  ButtonBox->pack_start(*QButton, Gtk::PACK_SHRINK);
  MainBox->pack_start(*ButtonBox, Gtk::PACK_SHRINK);
  // Connect Quit-Button to signal handler
  QButton->signal_clicked().connect(SigC::slot(*this, &ConstraintGui::on_button_quit));

  // Add VBoxLeft and VBoxRight to HWidgetBox
  HWidgetBox->pack_start(*VBoxLeft);
  HWidgetBox->pack_start(*VBoxRight);

  // Add box with all my widgets to the Notebook page
  Notebook->append_page(*HWidgetBox, "Constraints #1");


  show_all_children();

  std::cout << "END   ConstraintGui::showGui()" << std::endl;
}





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