遍历模型行
Gtk::TreeModel通过children()方法提供了标准C++容器库风格的子代迭代器。你可以使用熟悉的begin()和end()方法递增迭代器,如下所示:
auto children = refModel->children(); for (auto iter = children.begin(), end = children.end(); iter != end; ++iter) { auto row = *iter; //Do something with the row - see above for set/get. }
如果你总是想迭代整个范围,则可以使用C++基于范围的更简洁的for循环语法:
for (auto row: refModel->children()) { //Do something with the row - see above for set/get. }
- 10.3.1. 子行