Results 1 to 6 of 6

Thread: Anyway of updating a QTableView when model signals turned off?

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Anyway of updating a QTableView when model signals turned off?

    Hi,

    When I block signals on my model which my tableview uses it is so much faster at updating, but it only updates if I click on the tableview ( repaint ). Was wondering if there is a way to update the view without having to do this?

    Regards,
    Steve

  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: Anyway of updating a QTableView when model signals turned off?

    Unblock signals on time and emit layoutChanged() or reset the model. Or better yet - insert all items at once into the model.

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Anyway of updating a QTableView when model signals turned off?

    Hi,

    What do you mean by unblock signals on time? This after something is inserted? Unfortunately, the data in the model is continuously updated, so I guess I can't insert all items at once?

    Regards,
    Steve

  4. #4
    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: Anyway of updating a QTableView when model signals turned off?

    There is no such thing as "continously". You can update the model every second or so with all items gathered through that time. I'm sure your users won't mind a small lag.

  5. #5
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Anyway of updating a QTableView when model signals turned off?

    Thanks,

    I am updating the model every 5 milliseconds, the model is preloaded with data and certain parts of this data is updated ( such as reading signal from a car for the rpm ).

    This is the code I have now which is called every 5 milliseconds :

    Qt Code:
    1. void DACanTreeModel::updateTable( QString strData, QString strId )
    2. {
    3. QList<QObject*> *pList = theApp->m_dcb.GetSignalList();
    4. if( pList )
    5. {
    6. for( int i = 0; i < pList->count(); i++ )
    7. {
    8. CDADcb::CSignal* pSignal = (CDADcb::CSignal*)pList->at(i);
    9.  
    10. // This signal belong to this CAN id, there can be many signals that do
    11. if( pSignal->m_strId == strId )
    12. {
    13. // we need to do the conversion here - TODO
    14. pSignal->m_strRawData = strData;
    15. pSignal->m_nCount++;
    16. }
    17. }
    18. emit layoutChanged();
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

  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: Anyway of updating a QTableView when model signals turned off?

    Change 5 miliseconds to 500 miliseconds. 5ms i 1/200 of a second - human eye can't distinguish anything that's shorter than 0.05s (50ms). And don't block signals, it's not required in this situation.

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.