Hi Pierre,
Have a look at setRootIndex. Both QListView and QTableView can point anywhere within a tree model. Hint: When you can't find a function in a Qt class - make sure to click on the 'List of all members' link in the Assistant. Especially the more high level classes! Despite the name, the abstract base classes often have loads of in-built functionality. Hope that helps, Tony From: interest-bounces+tony=rightsoft.com...@qt-project.org [mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf Of Pierre-Étienne Messier Sent: Thursday, 27 September 2012 11:41 PM To: interest@qt-project.org Subject: [Interest] Tree Model and QListView Hi, Let's take the Simple Tree Model example ( http://qt-project.org/doc/qt-4.8/itemviews-simpletreemodel.html ) with the TreeModel and TreeItem classes. Let's say the internal data structure looks like this: root | + Category1 |------ Item |------ Item |------ Item | + Category2 |------ Item |------ Item |------ Item | ... I want to display that model inside a custom QListView to only show one Category at a time. So far, I ran a few tests and for example, setting the root element (in the model) as Category2 will indeed show only Category2 in the QListView (desired behavior). I want that when navigating with the keyboard arrows left-right keys would "reset" the model root node inside the QListView (Category1, then Category2 and so on). Would it be a good idea to: 1. Subclass QListView to catch the Left/Right arrow keypress 2. Destroy the current model in the view, creating a new model with the new desired root element 3. Replace the model in the view by the new one On paper, it seems quite inefficient to me. Any experience with that kind of operation? Could I just do this all inside one model instead? Thanks, Pierre-Étienne Messier
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest