Results 1 to 4 of 4

Thread: Model with two very different views

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Model with two very different views

    You're right, that's the way to go; but I'm already using a QSortFilterProxyModel to enable the user to filter the QStringListModel content based on regular expressions. Can you chain together multiple QSortFilterProxyModels (i.e., originalSource->QSortFilterProxyModel to produce item list->QSortFilterProxyModel to allow user filtering)?

    Cheers,
    Martin

  2. #2
    Join Date
    Apr 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Model with two very different views

    I've done this, but I'm encountering a problem. My core model is a DomModel object, taken directly from the SimpleDomModel example. That works well with the tree view. Then I'm using my own QSortFilterProxyModel descendant to filter the output, like this:

    bool HcmcXmlIdFilter::filterAcceptsRow ( int source_row, const QModelIndex &source_parent ) const{
    DomItem *parentItem;

    if (source_parent.isValid()){
    parentItem = static_cast<DomItem*>(source_parent.internalPointe r());
    DomItem *childItem = parentItem->child(source_row);
    if (childItem){
    QDomNode n = childItem->node();
    if (n.isElement()){
    if (n.toElement().hasAttribute("xml:id")){
    return true;
    }
    }
    }
    }
    return false;
    }

    However, no content is showing up in the QListView. Even when I set that function to return true by default, only the top level elements show up in the list; child elements in the tree do not seem to be processed. Any suggestions as to what I'm doing wrong?

    Cheers,
    Martin

Similar Threads

  1. how to disable views from a model
    By zeeeend in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 21:14
  2. Question about a model with multiple views
    By awhite1159 in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2008, 00:27
  3. 2 Views 1 Model
    By PrimeCP in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2007, 01:40
  4. Model/Views Woes
    By Scorp1us in forum Qt Programming
    Replies: 3
    Last Post: 8th February 2007, 03:10
  5. Model Views and QLabel
    By naresh in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2006, 15:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.