C++ (Qt)#include <QApplication>#include <QTableView>#include <QStandardItemModel>#include <QKeyEvent> class TableView : public QTableView{public: TableView( QWidget* p = 0 ) : QTableView( p ) {} void keyPressEvent( QKeyEvent* e ) { qWarning( "key=%d", e->key() ); switch( e->key() ) { case Qt::Key_Insert: qWarning( "Insert key pressed..." ); default: break; } QTableView::keyPressEvent( e ); }}; int main( int argc, char** argv ){ QApplication app( argc, argv ); TableView tv; QStandardItemModel model; tv.setModel( &model ); QStringList colorNames = QColor::colorNames(); model.insertColumns( 0, 1 ); model.insertRows( 0, colorNames.size() ); model.setHeaderData( 0, Qt::Horizontal, "Known Colors", Qt::DisplayRole ); for( int i = 0; i < colorNames.size(); ++i ) { QModelIndex index( model.index( i, 0, QModelIndex() ) ); model.setData( index, colorNames[i], Qt::DisplayRole ); model.setData( index, QColor( colorNames[i] ), Qt::DecorationRole ); } tv.show(); return app.exec();}