Create treeView Path from Glib::ustring

I want to be able to select the row of the treeView by creating a loading the particular index using Glib::ustring

TreeView diagram shown below would help you visualize.

// Creating TreeSelection pointer
Glib::RefPtr<Gtk::TreeSelection> treeViewSelection = treeView->get_selection();
 Gtk::TreePath *path = Gtk::TreePath::TreePath(Glib::ustring("1:1"));

const Glib::ustring& bgPath("0");
// Can create TreePath directly from Glib::ustring according to this documentation
Gtk::TreePath selPath = Gtk::TreePath::TreePath(bgPath);

When I Compile the code I get his error

error: cannot call constructor Gtk::TreePath::TreePath directly [-fpermissive]
Gtk::TreePath selPath = Gtk::TreePath::TreePath(bgPath);

What am I doing wrong here?

you want

Gtk::TreePath selPath = Gtk::TreePath(bgPath)

or in a more modern syntax

Gtk::TreePath selPath { bgPath };

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