Paint issue with QTableView and QAbstractTableModel



  • Hello,
    I have created a custom data model for a QTableview. I use the function below to append lines in the model (it is a logger widget). When I do several subsequent calls to that function, the widget appears to paint the wrong content for some cells. It even occured one time that a cell was half paint with a content and half with another content. According to the test with "isGuiThread", every call is done on the gui thread. Is there something I'm doing wrong when I insert and remove lines?

    Thanks.

    @void DataModel::appendLog(LogEventPtr event)
    {
    {
    const bool isGuiThread =
    QThread::currentThread() == QCoreApplication::instance()->thread();
    if(!isGuiThread)
    event->Message += QString::fromLatin1(" [Bad thread]");

    beginInsertRows(QModelIndex(), static_cast<int>(mMessageQueue.size()),
        static_cast<int>(mMessageQueue.size()));
    mMessageQueue.push_back(event);
    endInsertRows();
    if(mMaxLogLength)
    {
      int lRowToRemove = static_cast<int>(mMessageQueue.size()) - mMaxLogLength;
      if(lRowToRemove > 0)
      {
        beginRemoveRows(QModelIndex(), 0, lRowToRemove - 1);
        mDroppedEntriesCount += lRowToRemove;
        for(int i = 0; i < lRowToRemove; ++i)
        {
          mMessageQueue.pop_front();
        }
        endRemoveRows();
      }
    }
    

    }
    }@
    !http://alphonse.dyndns.org:8000/Qt/logger.png(paint_issue)!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.