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"));
refInTTreeSelection->select(rs);

const Glib::ustring& bgPath("0");
// Can create TreePath directly from Glib::ustring according to this documentation
// http://transit.iut2.upmf-grenoble.fr/doc/gtkmm-3.0/reference/html/classGtk_1_1TreePath.html#abed03e843e12b7b64db39fae5b26cc30
Gtk::TreePath selPath = Gtk::TreePath::TreePath(bgPath);
refInTTreeSelection->select(selPath);

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.