Results 1 to 5 of 5

Thread: QSortFilterProxyModel with changing data

  1. #1
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QSortFilterProxyModel with changing data

    HI!

    I have a list of descriptors. These descriptors are constantly changing data. I build the tree items in the model from these descriptors.
    Qt Code:
    1. m_pMyTreeModel = new CMyTreeModel();
    2. //
    3. m_pMyTreeModel->initializeModel(m_listDescriptors);
    4. //
    5. m_pFilterModel = new CMySortFilterProxyModel(this);
    6. //
    7. m_pFilterModel->setSourceModel(m_pMyTreeModel);
    8. //
    9. m_pTree->setModel(m_pFilterModel);
    To copy to clipboard, switch view to plain text mode 
    Each descriptor is connected to the item that is created in the model. I am emitting the signals
    Qt Code:
    1. layoutAboutToBeChanged()
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. layoutChanged()
    To copy to clipboard, switch view to plain text mode 
    in a timer so that the data is updated correctly in the view.

    The problem is that the code gets very slow with few thousand items (3000+).
    I tried to implement the functions for better performance:

    Qt Code:
    1. bool hasChildren(const QModelIndex &parent) const;
    2. bool canFetchMore(const QModelIndex &parent) const;
    3. void fetchMore(const QModelIndex &parent);
    To copy to clipboard, switch view to plain text mode 

    but get stuck with the
    Qt Code:
    1. void fetchMore(const QModelIndex &parent);
    To copy to clipboard, switch view to plain text mode 
    function. In this function i should create the tree items, but the problem is that i have no descriptors here to connect them to the tree items.
    I don't know if this is the best approach to update the data in the model. I think that there is a better way to do this, but have no idea how.

    Please help.

  2. #2
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSortFilterProxyModel with changing data

    Can someone help me please?

  3. #3
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSortFilterProxyModel with changing data

    OK, I changed the tree item and made it more lightweight, not it is no more derived from QObject. I am now using a QMap with the descriptors and items. The performance is good now, but I am facing another problem that I had also before. There are to mani handles open - with 5000 items, there are arounf 15000 handles and the memory is raising beyond 250 MB.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSortFilterProxyModel with changing data

    What is a "handle" and why do you think they consume about 16 kilobytes a piece? Are you perhaps allocating but never freeing objects in memory as the model gets used?

  5. #5
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSortFilterProxyModel with changing data

    The problem was in an library that I was using and not Qt related. Thanks for the help.

Similar Threads

  1. Replies: 2
    Last Post: 12th May 2010, 13:32
  2. Replies: 8
    Last Post: 25th April 2010, 21:19
  3. Replies: 2
    Last Post: 10th August 2009, 09:45
  4. Replies: 3
    Last Post: 21st December 2008, 12:23
  5. QSortFilterProxyModel
    By evgenM in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2007, 11:53

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.