C++ (Qt)#include <QApplication>#include <QTableView>#include <QItemDelegate>#include <QStandardItemModel>#include <QPainter>#include <QTimer>#include <QDebug> class Delegate : public QItemDelegate{ Q_OBJECTpublic: Delegate() : m_state( false ) {} void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const; public slots: void stateChanged() { m_state = !m_state; } private: bool m_state;}; void Delegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const{ if( !index.isValid() ) return; painter->save(); QString val = index.data( Qt::DisplayRole ).toString(); if( val == "A" ) painter->drawText( option.rect, m_state? "Alarm" : "" ); else painter->drawText( option.rect, val ); painter->restore();} int main( int argc, char *argv[] ){ QApplication app( argc, argv ); QStandardItemModel model( 10, 10 ); model.setItem( 1, 0, new QStandardItem( "A" ) ); model.setItem( 3, 0, new QStandardItem( "A" ) ); model.setItem( 4, 0, new QStandardItem( "A" ) ); Delegate delegate; QTableView view; view.setModel( &model ); view.setItemDelegateForColumn( 0, &delegate ); view.show(); // Таймер меняет состояние и заставляет перерисоваться view QTimer timer; QObject::connect( &timer, SIGNAL( timeout() ), &delegate, SLOT( stateChanged() ) ); QObject::connect( &timer, SIGNAL( timeout() ), view.viewport(), SLOT( update() ) ); timer.start( 1000 ); return app.exec();} #include "main.moc"
class MyDataModel : public QAbstractItemModel {....virtual void data( ..); // добавить выдачу для Qt::BackgroundRole...void NextBlink( void ) { mBlinkState = (mBlinkState + 1) % 2; }QVector <QModelIndex> mBlinkCell; // массив мигающих ячеекint mBlinkState: // напр. 0 = синий, 1 = красный и.т.п.};