Solve bug of completer in GridAccount
This commit is contained in:
		| @@ -53,3 +53,28 @@ void TabDelegate::setEditorData(QWidget *editor, | ||||
|  | ||||
|     line->setText(s.trimmed()); | ||||
| } | ||||
|  | ||||
| /* | ||||
|  Implement editorEvent due to a "feature" in Qt : If we have a QLineEdit with a completer | ||||
|  and we press a key on a non edited cell, editor immediatly returns (it's perhaps a focus | ||||
|  problem) | ||||
|  */ | ||||
| bool TabDelegate::editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index ) | ||||
| { | ||||
|     if (event->type() == QEvent::KeyPress && _completer) | ||||
|     { | ||||
| 	QTableWidgetItem* item = _grid->item(index.row(), index.column()); | ||||
| 	if (item->text() == "") | ||||
| 	{ | ||||
| 	    _grid->editItem(item); | ||||
| 	    QLineEdit* line = qobject_cast<QLineEdit *>(_grid->cellWidget(index.row(), index.column())); | ||||
| 	    QKeyEvent* kevent = dynamic_cast<QKeyEvent *> (event); | ||||
| 	    line->setText(kevent->text()); | ||||
| 	    _completer->setCompletionPrefix(kevent->text()); | ||||
| 	    _completer->complete(); | ||||
| 	    return true; | ||||
| 	} | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user