Results 1 to 3 of 3

Thread: Changing the view refresh policy when dealing with a fast changing model

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Changing the view refresh policy when dealing with a fast changing model

    I have a view displaying the items of a fast changing model.
    Sometimes the view cannot keep up with displaying new data making the GUI less responsive.
    So I would like to know if there is a way to change the displaying policy of the view, f.e. making the view to refresh it content on a timer event.

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    658
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing the view refresh policy when dealing with a fast changing model

    items of a fast changing model.
    may be it takes lonk time to return scene()->update() ...

    if there is any long running (algorithm/formula/calculation) for the items try to port it to QThread() or use qApp->processEvents();

    also check ..
    Qt Code:
    1. setViewportUpdateMode(FullViewportUpdate); // to your area ..
    To copy to clipboard, switch view to plain text mode 
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing the view refresh policy when dealing with a fast changing model

    in the QAbstractItemView in setModel() method some connections are set:
    Qt Code:
    1. connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
    2. this, SLOT(dataChanged(QModelIndex,QModelIndex)));
    3. connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
    4. this, SLOT(rowsInserted(QModelIndex,int,int)));
    5. connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
    6. this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
    To copy to clipboard, switch view to plain text mode 
    What I would try is to disconnect those connections, connect rowsInserted() and dataChanged() to my own slot to collect changed/inserted rows, and then in some slot called on QTimer timeout() just simply call proper slot in the view, and clear own changed/inserted collection.
    Didn't tested and I am not sure if it is the best way.
    P.S. those slots are protected members in QAbstractItemView so you have to subclass the view you are using.
    Last edited by faldzip; 10th August 2009 at 09:46. Reason: spelling error
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Replies: 9
    Last Post: 7th November 2006, 15:10

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