TreeStore clear not erasing the previous data

I am creating a TreeStore Create like this only during application builder is called

imgTPTreeViewPointer = Gtk::TreeStore::create(imgTPTreeColumn);

Using Gtk::TreeModelColumnRecord Class Reference to add row but no function to remove rows!

I’m creating a scrolled window to insert TreeStore using ReferencePointer

    Gtk::Box *imgTPTreeBox;
    Gtk::ScrolledWindow *imgTPTreeScrolWin;
    Gtk::TreeView *imgTPTreeView;
    Glib::RefPtr<Gtk::TreeStore> imgTPTreeViewPointer;  
    Gtk::TreeModel::Row rowTP;

    //This is imgTPTreeColumn definition in the header file
    class imgTPTreeModelCol: public Gtk::TreeModel::ColumnRecord
    {
    public:
        Gtk::TreeModelColumn<Glib::ustring> col_name;

        imgTPTreeModelCol()
        {    add(col_name);}

    };
    imgTPTreeModelCol imgTPTreeColumn;

imgTPTreeViewPointer = Gtk::TreeStore::create(imgTPTreeColumn);
    builder->get_widget("imgTPTreeView"+concatString,imgTPTreeView);
    imgTPTreeView->set_model(imgTPTreeViewPointer);
    imgTPTreeView->set_headers_visible(false);


    imgTPTreeView->set_activate_on_single_click(true);
    imgTPTreeView->append_column("",imgTPTreeColumn.col_name);

I clear TreeStore using imgTPTreeViewPointer->clear()

When I try to iterator over the children of the TreeStore using imgTPTreeViewPointer after clear using this code

    int numberOfTiePoints = imgTPTreeViewPointer->children().size();
    if (numberOfTiePoints>0)
     {
        std::cout<<"Start for loop in case of tiepoints"<<std::endl;
        auto children = imgTPTreeViewPointer->children();
        for (auto iter = children.begin(),end = children.end();iter != end;++iter)
        {
            auto row = *iter;

            // Extract the data in the selected latest row
            Glib::ustring slBgRow = row[imgTPTreeColumn.col_name];

            // Print of data on the terminal
            std::cout<<"TP Item: "<<slBgRow<<std::endl;
            std::cout<<"iter: "<<iter<<std::endl;
            Gtk::TreePath spath = Gtk::TreePath(iter);
            std::string streePathString = spath.to_string();
            std::cout<<"path: "<<streePathString<<std::endl;
        }
}

I get no children being printed, but I can see the previous TreeStore data still being displayed on the GUI
Even after using unset_model then doing set_model again. After clearing using imgTPTreeViewPointer->clear()

        imgTPTreeView->unset_model();
        imgTPTreeView->set_model(imgTPTreeViewPointer);
        imgTPTreeView->set_headers_visible(false);

How do I fix it? I’m confused

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