Get the activated row data from the sorted ColumnView in Gtkmm

Deprecated - Gtk::TreeView Class has a
Public Member Functions
void row_activated (const TreeModel::Path & path, TreeViewColumn &column)
Activates the cell determined by path and column.

Gtk4 - Gtk::ColumnView Class has
Glib::SignalProxy< void(guint)> signal_activate ()
Emitted when a row has been activated by the user.

Issue:
In a sorted view
- TreeView’s “row_activated” gives a very easy way to get the activated row data using the ‘path’ and ‘column’
- How can we get the activated row data using the ColumnView’s “signal_activate” returned ‘position’ value of a sorted view?

Sorry, but I don’t know if I understand the question. ColumnView’s “signal_activate” returns the position of the entire row in the ColumnView, if you want a specific cell to trigger some behavior when clicked, wouldn’t it be better to add a double click event that generates this behavior to the setup function when building that cell?

What is your overall goal? Why would you need to know which cell was activated?

Thank you for your reply.
Sorry for my confusing writing. The purpose is to get data from the activated row.

For example, I have two rows appended to the view. At startup, the 1st row is “aaa”, and the 2nd row is “bbb”. If I activate (ie double click) the 1st row, the returned position is 0. List store ‘gets item’ with argument 0, will return “aaa”.
Then, I sort the column. 1st row will become “bbb”, and the 2nd row will become “aaa”. If I activate the 1st row (now it is “bbb”), position 0 is returned correctly. But, liststore ‘get item’ with argument 0, returns “aaa”. Should it be “bbb”?

It seems that row data in liststore are in original order. Sorted row data are stored somewhere as.

Thank you.

Ok, now I understand the problem. Are you using a Gtk.SortListModel to sort the columns? If yes, the model has the same properties as a list, so instead of using ListStore.get_item(), you can use SortListModel.get_item(). This should return the correct item from which you can extract the value later.

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