Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-45978

Signal dataChanged of QAbstractTableModel doesnot work in QT5

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Incomplete
    • Affects Version/s: 5.4.1
    • Fix Version/s: None
    • Component/s: Widgets: Itemviews
    • Labels:
      None
    • Environment:
      WIN7 x64, QT5.3.2/5.4.1 in MingW

      Description

      I have a tableview in my program. It always works very well in QT4. As you will not fix the bug:
      https://bugreports.qt.io/browse/QTBUG-44722

      I have to update my project to QT5
      And there is a new problem with this code:

      void TableModel::updateData(int i) // child class of QAbstractTableModel
      {
          if (i<0) return;
          QModelIndex t1 = index(i, 0); 
          QModelIndex t2 = index(i, 5);
           qDebug() << "111_____TableModel::updateData " << i;
          emit dataChanged(t1, t2); 
      }
      

      It should update the data of table of GUI, but it doesnot work in QT5.
      Even I write like this:

      void TableModel::updateData(int i)
      {
      	if (i<0) return;
          QModelIndex t1 = index(i, 0); 
          QModelIndex t2 = index(i, 5);
          qDebug() << "111_____TableModel::updateData " << i;
      
          QVector<int> qq;
          qq.append(Qt::DisplayRole);
          qq.append(Qt::DecorationRole);
          qq.append(Qt::EditRole);
          qq.append(Qt::ToolTipRole);
          qq.append(Qt::StatusTipRole);
          qq.append(Qt::WhatsThisRole);
          qq.append(Qt::SizeHintRole);
          qq.append(Qt::AccessibleTextRole);
          qq.append(Qt::AccessibleDescriptionRole);
          qq.append(Qt::UserRole);
          emit dataChanged(t1, t2, qq);
      }
      

      It doesnot work too.
      -----------------------------------------------------
      The correct logic is:
      I call TableModel::updateData(int i) to emit dataChanged(t1, t2, qq); , and then QT will call QStyledItemDelegate::paint() (this function has be overrided by my child class) to paint the table of GUI. But now the 2nd step will not be executed.Why?

      I guess maybe QT5 forget the connection of signal dataChanged and QStyledItemDelegate::paint() ?

      Finally, I test the code above in QT5.11/5.32/5.41, there is the same problem. Can you help me to confirm this is the bug of QT5? Thanks in advance.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            stlcours cliff cours
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes