When I try to add a Gtk::box to a grid from another function upon button click I get the error:
gtk_grid_attach_next_to: assertion '_gtk_widget_get_parent (child) == NULL' failed
But if I copy the code from the add function(card_add) to the main function (kanban_init) It will be added to the grid without issue but I need to add a new box to the grid upon button press, which calls the card_add function to add the box to the grid.
In the header file (tabs.h):
Gtk::Grid kanbanGrid;
Gtk::Box todoBox, progressBox, doneBox, backlogBox;
Gtk::Box newCard;
Gtk::Label cardTitle, cardDesc
In the main function(tabs::kanban_init):
tAdd.signal_clicked().connect(sigc::mem_fun(*this, &tabs::card_add));
kanbanGrid.attach(todoBox, 1, 1);
kanbanGrid.attach(progressBox, 2, 1);
kanbanGrid.attach(doneBox, 3, 1);
kanbanGrid.attach(backlogBox, 4, 1);
In the add new box function (tabs::card_add):
newCard.set_size_request(300, 30);
newCard.pack_start(cardTitle, Gtk::PACK_SHRINK);
newCard.pack_start(cardDesc, Gtk::PACK_SHRINK);
cardTitle.set_label("title");
cardDesc.set_label("description");
kanbanGrid.attach_next_to(newCard, todoBox, Gtk::POS_BOTTOM);
tAdd
? I would like to try to reproduce your issue. – BobMorane