Re: Question about Gtk::Notebook::append_page



What I would do is,
  1. Create a class derived from Gtk::HBox or Gtk::VBox,
  2. Populate this class with the content (in your case the entry widgets),
  3. Add memeber functions to set / get values of the widgets (or make though widgets public members, though its a bad practice),
  4. Then add managed instances of my class to the notebook like given below.
            CMyClass * pClass = Gtk::manage(new CMyClass);
            Notebook.append_page(*pClass);

            //Set contents for this page
            pClass->set_.....
regards
Mohith Manoj

On Fri 28-Dec-2012 02:02, Mislav Blazevic wrote:
Hi, I'm new to Gtkmm and I need some help.

I want each page to contain same widgets, but have different text in entries, so since I store data from Gtk::Entry elsewhere, I want to reuse same widgets.

This is What I did:

First created initial page:
Notebook.append_page(Box); // Box contains all widgets

I also added a button for creating a new page:
void Somewhere::ButtonClicked()
{
    Notebook.append_page(Box); //<--- Same Box
}

And, on notebook switch page:
void Somewhere::ChangedPage()
{
// restore data from entries for this page from std::list<DatazFromEntries>
}

Now, this crashed(?) because I was adding same Box to both pages.
Any workaround for this? Or I will have to create a copy of all widgets for each page(Expensive?)?


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


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