[Qt-interest] Forbid to close the editor of the QTableWidget
Iurii Gordiienko
hordi at ukr.net
Thu Apr 2 11:06:14 CEST 2009
Hi Please, help me with solution... I should implement unique values for all items in one column of the QTableWidget... I reimplemented the "closeEditor function", I can check the unique values, but I can't forbid to close the editor of that item (Now I don't see any other suitable solution for that). I have a plan to keep in edit-mode (or may be return to old values) while properly values will not be entered... ----%<------------------------------ void TableWidget::closeEditor( QWidget* editor, QAbstractItemDelegate::EndEditHint hint )
{
QModelIndex idx = currentIndex();
if(idx.column()==_uniqueColumn){
QLineEdit* p = dynamic_cast<QLineEdit*>(editor);
if(p){
QString s = p->text();
//find equal words
int row = rowCount();
int cur_row = idx.row();
for(int i=0;i<row;++i){
if(cur_row==i){
continue;
}
QTableWidgetItem* p = item(i,_uniqueColumn);
if(!p){
continue;
}
if(p->data(Qt::DisplayRole).toString()==s){
// (bool)edit(idx,QAbstractItemView::AllEditTriggers,0);
return;
}
}
}
QTableWidget::closeEditor(editor,hint);
}
---->%------------------------------
Qt-4.5.0
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090402/2276f31c/attachment.html
More information about the Qt-interest-old
mailing list