[Qt-interest] Forbid to close the editor of the QTableWidget
Malyushytsky, Alex
alex at wai.com
Fri Apr 3 21:20:38 CEST 2009
Have you tried not to call QTableWidget::closeEditor(editor,hint); ?
According to documentation this function closes editor.
Another approach is you can always reopen it, right?
Alex
________________________________________
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Iurii Gordiienko
Sent: Thursday, April 02, 2009 2:06 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Forbid to close the editor of the QTableWidget
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
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list