Results 1 to 2 of 2

Thread: Best practice for dynamic update of QTabelView

  1. #1
    Join Date
    Mar 2020
    Posts
    1
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Best practice for dynamic update of QTabelView

    I have an application(QT 5.11.2, linux) with 200 cells. The text in 20 … 40 cells change every second. Now I us the dataChanged signal for update the QTabelView. I use one signal per cell.
    If I send a dataChanged with more than one cell, always the whole table was updated.

    Is QTableView the right widget or is QTableWidget better?

    Is there a better way to update the cells?

    Code samples
    class Xdatamodel : public QAbstractTableModel
    void Xdatamodel::setModelData(int rowindex, int dataitem, QString value)
    {
    dataMatrix[rowindex].operator [](dataitem) = value;
    emit(dataChanged(index(rowindex,dataitem), index(rowindex,dataitem),
    }

    QVariant Xdatamodel::data(const QModelIndex &index, int role) const
    {
    if (role == Qt:isplayRole || role == Qt::EditRole)
    {
    return dataMatrix[index.row()].at(index.column());
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best practice for dynamic update of QTabelView

    Since you're already using a custom model you have to use QTableView. One signal per cell is fine.

  3. The following user says thank you to ChristianEhrlicher for this useful post:

    regenwo62 (23rd March 2020)

Similar Threads

  1. Remove row button in QTabelview
    By guidupas in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2014, 15:31
  2. Update QGraphicsScene - Best Practice
    By vinaykusta in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2011, 05:52
  3. Special delegate for QTabelView
    By kunashir in forum Qt-based Software
    Replies: 0
    Last Post: 17th March 2011, 14:22
  4. dynamic QLabel update
    By satanowicz in forum Newbie
    Replies: 8
    Last Post: 26th May 2010, 00:20
  5. Change database data in the QTabelView
    By sophister in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2009, 17:40

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.