Results 1 to 6 of 6

Thread: Blocking updates on views

  1. #1
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Blocking updates on views

    Hi,

    is there a way to block all updates on a view (e.g. TableView). I want to update the views only if I emit signal.

    Did anybody know a way how i can do this?

    Best Regards
    NoRulez

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Blocking updates on views

    There is a property available - QWidget::updatesEnabled but be sure you know what you are doing.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: Blocking updates on views

    Thank you very much, this seems to solve my problem.

    Best Regards
    NoRulez

  4. #4
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Re: Blocking updates on views

    Ok, it doesn't solve the problem, which means that the gui is still blocking.

    I've attached a small example which demonstrate the problem.

    I hope someone could help.

    Best Regards
    NoRulez
    Attached Files Attached Files

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Blocking updates on views

    Do not show all your data at once, use fetchmore.
    http://doc.qt.nokia.com/4.6/itemviews-fetchmore.html

    Do your data parsing or loading in a thread or asynchronous and use that data to populate your model. Use fetchmore to prevent blocking.

    Edit: To be more clear: in your thread you have this line: m_pModel->insertRows(m_pModel->rowCount(), 1);
    Leave adding rows to the model, not your thread. Create a custom model, keep a list of data inside the model and add data to that list via your thread (signals will work very well for this). Then, when you scroll in your view, the model will check if there's more data to display and adds the next few rows.
    Last edited by tbscope; 30th April 2010 at 12:42. Reason: Be more clear

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Blocking updates on views

    QObject subclasses are not thread-safe, don't try accessing the model directly from a worker thread or this will lead to trouble. Use signals and slots instead. And update your model in chunks, not a row at a time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. installing updates
    By uj in forum Installation and Deployment
    Replies: 3
    Last Post: 13th July 2012, 08:15
  2. QMenuBar Updates
    By johnmauer in forum Qt Programming
    Replies: 5
    Last Post: 20th January 2010, 13:35
  3. Thread updates progress bar
    By GianMarco in forum Qt Programming
    Replies: 7
    Last Post: 12th October 2009, 13:29
  4. Painting updates
    By QbelcorT in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 29th September 2008, 00:48
  5. QDataTable Inserts and Updates
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 23:23

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.