How to make cells blinking in a QTableView



  • Hi,

    I am trying to 'blink' a cell in a QTableView each time the content changes. By blinking I means the background color is set to a particular color then after a short time, returns to the original color.

    I thinking about a way by QItemDelegate, but do no figure out how to 'resent' an event to the delegate object to set the background back to original color without 'stimulation' of the model. May be by a timer ?!

    Thanks for all your comments, I am stuck...



  • You could do it in the model you have.
    Yust create a timer (singleSAhot would be enough) and emit the dataChanged() signal from the model. By switching a value that indicates the color you've got it.

    The delegate does not work here, as it is used for painting but does not trigger it.

    so, in pseudo code, it would be:

    @
    MyModel::setData()
    {
    m_blinkCell = XXX;
    QTimer::singleShot(..., resetBlink);
    emit dataChanged(changedCell);
    }

    MyModel::data()
    {
    if(index.cell == m_blinkCell && role==background)
    return Qt::red;
    return defaultImpl;
    }

    MyModel::resetBlink()
    {
    m_blinkCell = none;
    emit dataChanged(changedCell);
    }
    @



  • Impressive Gerolf... I am trying your idea now
    thanks :)



  • If you have any further questions, just ask. It was a short shot, but it will work :-)


Log in to reply
 

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