class MyTableItem : public QTableItem{public: MyTableItem( QTable *table, EditType et, const QString &text, int align ) : QTableItem( t, et, text ), m_align( align ) {} ... void setAlignment( int align ) { m_align = align; } virtual int alignment() const { return m_align; }private: int m_align;};
int QTableItem::alignment() const{ bool num; bool ok1 = FALSE, ok2 = FALSE; (void)text().toInt( &ok1 ); if ( !ok1 ) (void)text().toDouble( &ok2 ); // ### should be .-aligned num = ok1 || ok2; return ( num ? AlignRight : AlignLeft ) | AlignVCenter;}
int QTableItem::alignment() const{ return AlignLeft | AlignVCenter;}
MyTable::setText() { QTableItem *itm = item( row, col ); if ( itm ) { itm->setText( text ); itm->updateEditor( row, col ); updateCell( row, col ); } else { QTableItem *i = new MyTableItem( this, QTableItem::OnTyping, text, QPixmap() ); setItem( row, col, i ); }}