Dra och släpp
Gtk::TreeView implementerar redan enkelt dra-och-släpp när den används med Gtk::ListStore- eller Gtk::TreeStore-modellerna (sedan gtk 4.8). Om nödvändigt låter den dig också implementera mer komplext beteende när objekt dras och släpps, med det vanliga Dra och släpp-API:t.
Reorderable rows
If you call Gtk::TreeView::set_reorderable() then your TreeView's items can be moved within the treeview itself. This is demonstrated in the TreeStore example.
However, this does not allow you any control of which items can be dragged, and where they can be dropped. If you need that extra control then you might create a derived Gtk::TreeModel from Gtk::TreeStore or Gtk::ListStore and override the Gtk::TreeDragSource::row_draggable_vfunc() and Gtk::TreeDragDest::row_drop_possible_vfunc() virtual methods. You can examine the Gtk::TreeModel::Paths provided and allow or disallow dragging or dropping by returning true or false.
Detta demonstreras i dra-och-släpp-exemplet.