Results 1 to 6 of 6

Thread: I dont want to update QTableView after every beginInsertRows()

  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default I dont want to update QTableView after every beginInsertRows()

    Hi!

    I am using QTableView which is connected with some model. In the model the data is changing very fast in the background.

    Is it possible to update the QTableView for example only every second?

    Greetings from Vienna

    Mike

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: I dont want to update QTableView after every beginInsertRows()

    I don't think there is direct way to do so.

    One way to do so is to maintain a internal state in the model, and give new data to the view only when you want it to get updated ( by emitting reset() signal from model). You need to accordingly handle all the model interface calls (rowCount(), columnCount(), data(), index(), setData(), etc).

    Another way (with out maintaining internal state in model) would to maintain two instances of model, one for updating in background (not connected to any views), another to display (connected to views), when ever you wan the views to get updated, just switch the model, and use the other one for background updating again. Decision has to made keeping various factors like typical size of model, typical time to update the complete model, typical refresh time etc.

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: I dont want to update QTableView after every beginInsertRows()

    Hi Santosh,

    Thxs for your answere!
    It seems that I need a separate model for the TableView.

    I am not sure if I understood your solution with the reset signal. You mean, when adding or delete data to the model, I dont call beginInsertRows(), but before updating the TableView I have to call model->modelReset()?
    I think this is very expensive or?

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: I dont want to update QTableView after every beginInsertRows()

    I was suggesting to have two models

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: I dont want to update QTableView after every beginInsertRows()

    I meant your first way

  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: I dont want to update QTableView after every beginInsertRows()

    Quote Originally Posted by mikemc View Post
    Is it possible to update the QTableView for example only every second?
    Sure. Have a timer in your model that will fire once a second. Store all the changes to the incoming model in a waiting queue and process the queue (inserting the data into the model) when the timer fires.
    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. Update changes in QTableView to sqlite data base
    By nagabathula in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2011, 01:18
  2. Replies: 0
    Last Post: 11th November 2010, 22:36
  3. QTableView overwriting the editor with update
    By thePoet in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2010, 22:10
  4. QTableView update
    By inktomi in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2009, 15:18
  5. Replies: 9
    Last Post: 7th November 2006, 15:10

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.