QxMainDialog::QxMainDialog(){ connect(TableParam, SIGNAL(itemChanged(QTableWidgetItem *)),this,SLOT(itemChanged(QTableWidgetItem *)));}...void QxMainDialog::itemChanged ( QTableWidgetItem * item ){ if(item->column()==3){ // выбираю третий столбец QString localbuf = item->text(); qDebug() << localbuf; item->setData ( Qt::DisplayRole, QString::QString ( localbuf.size(), '*' ) ); }}
TrackDelegate::TrackDelegate(int durationColumn, QObject *parent) : QItemDelegate(parent){ this->durationColumn = durationColumn;}QWidget *TrackDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const{ if (index.column() == durationColumn) { QLineEdit *lineEdit = new QLineEdit(parent); lineEdit->setEchoMode(QLineEdit::Password); return lineEdit; } else { return QItemDelegate::createEditor(parent, option, index); }}
void TrackDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ if (index.column() == durationColumn) { QString text = index.model()->data(index, Qt::DisplayRole).toString(); QString buf(text.size(),'*'); drawDisplay(painter, option, option.rect, buf); drawFocus(painter, option, option.rect); } else{ QItemDelegate::paint(painter, option, index); }}
C++ (Qt)void TrackDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ if (index.column() == durationColumn) { QString text = index.model()->data(index, Qt::DisplayRole).toString(); QLineEdit edit; edit.setText(text); edit.setEchoMode(QLineEdit::Password); drawDisplay(painter, option, option.rect, edit.displayText()); drawFocus(painter, option, option.rect); } else{ QItemDelegate::paint(painter, option, index); }}
C++ (Qt)...private: mutable QLineEdit *lineEdit;...