Facing difficulties to use share QAbstractItemModel between QTreeView & QListView
Hello,
I have QAbstractItemModel implementation which share in two view [ QTreeView & QListView]
List view contains some filters like… All Type, Type 1, Type 2, Type 3. those types represented as parent item in Tree View.
So when i click on Type 1 from Tree View it will generate index click and set root index of list view by them. so it will display all child’s items from Type 1 will be listed in List View. Its works fine for me but,
When i want to use of combination of filters e.g. like Type 1 & Type 2, so in my list view it should display the list of all child’s of Type 1, & Type 2 but it could not be possible because i can set only one root index at a time to list view. So how can i achieve this ?
And same scenario above is applicable to All Type filter as well, how could i display all child’s of Tree view item to be listed in list view.
Any help will be really appreciated.
Thanks
Prashant Moglaikar
3 replies
Hi Gerolf,
Thanks for reply i have implementation of proxy model but could figure it out how to map list view model index to get my expected out put could you please give me some hint or any small example so i can get understand how its be implement ?
- {
- return ShowThis(index);
- }
- {
- bool retVal = false;
- //Gives you the info for number of childs with a parent
- if ( sourceModel()->rowCount(index) > 0 )
- {
- for( int nChild = 0; nChild < sourceModel()->rowCount(index); nChild++)
- {
- if ( ! childIndex.isValid() )
- break;
- retVal = ShowThis(childIndex);
- if (retVal)
- {
- break;
- }
- }
- }
- else
- {
- //qDebug()<<"type is "<<type;
- if ( ! type.contains(filterRegExp()))
- {
- retVal = false;
- }
- else
- {
- retVal = true;
- }
- }
- return retVal;
- }
Thanks
Prashant
You must log in to post a reply. Not a member yet? Register here!



