Gtkm Scrolled Window has no member function set_child error I am getting

I want to dynamically
ADD → notebook PAGE
ADD-> GRID (inside the PAGE)
ADD->ScrolledWindow(Inside GRID)
ADD->ViewPort(Inside ScrolledWindow)

Here’s the code

    std::cout<<"Cam incremented"<<std::endl;
	camString = "Camera: ";
	camGridName = "camGrid";
	camScrolledWindowName = "camScrollWindow";
	camViewPortName = "camViewPort";
	std::cout<<"Cam string created"<<std::endl;

	// camera number
	camString.append(std::to_string(totalCams));
	// camera grid name
	camGridName.append(std::to_string(totalCams));
	// camera scrolledWindow name
	camScrolledWindowName.append(std::to_string(totalCams));
	// camera scrolledWindow name
	camViewPortName.append(std::to_string(totalCams));

	std::cout<<"Cam string appended"<<std::endl;
	// Creating new page tab label
	Gtk::Label *cameraName = new Gtk::Label(camString);
	// Create a new grid
	Gtk::Grid *newGrid = new Gtk::Grid();
	// Set new grid name
	newGrid->set_name(Glib::ustring::format(camGridName));
	// Create a new scrolled window
	Gtk::ScrolledWindow *newScrollWindow = new Gtk::ScrolledWindow();
	// Create a viewport
	Gtk::Viewport *newViewPort = new Gtk::Viewport(Gtk::Adjustment::create(0,0,0, 0.5),Gtk::Adjustment::create(0,0,0, 0.5));
	// Set new scrolledwindow name
	newScrollWindow->set_name(Glib::ustring::format(camScrolledWindowName));
	// Set new viewport name
	newViewPort->set_name(Glib::ustring::format(camViewPortName));

	// Child widget, tab label
	cameraNotebook->append_page(*newGrid,camString);
	// Set new viewport widget as child of scrolledwindow
	newScrollWindow->set_child(*newViewPort);
	// Insert scroll Window to the grid 2,2 position
	newGrid->attach(*newScrollWindow,2,2,1,1);
	// cameraName->set_text(camString);
	std::cout<<"String Done"<<std::endl;
	// parameters
	// Used to store the cameralabels as a vector
	cameraLabels.push_back(cameraName);
	// Used to store the cameralabels as a vector
	cameraGrids.push_back(camGridName);
	// Used to store the cameralabels as a vector
	scrolledWindows.push_back(camScrolledWindowName);
	// Used to store the cameralabels as a vector
	viewPorts.push_back(camViewPortName);

	cameraNotebook->set_current_page(totalCams);
	std::cout<<"Append Done"<<std::endl;
	cameraNotebook->show();
	newGrid->show();
	newScrollWindow->show();
	newViewPort->show();
	cameraName->show();

I get this error

error: class Gtk::ScrolledWindow has no member named set_child; did you mean get_child
newScrollWindow->set_child(*newViewPort);

Don’t know what is wrong!

We do have a member function with gtk::ScrollWindow::set_child

Where did I got wrong?

You are (most probably) working with gtk3 while looking at the documentation for gtk4. You probably just want ->add(child) instead of ->set_child(child).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.