Hi,

In an editable QTableView, I added the following delegate:
Qt Code:
  1. SKGQueryDelegate::SKGQueryDelegate(QObject* parent, SKGDocument* iDoc, bool iModeUpdate):
  2. QItemDelegate(parent), document(iDoc), updateMode(iModeUpdate)
  3. {
  4. }
  5.  
  6. SKGQueryDelegate::~SKGQueryDelegate()
  7. {
  8. document=NULL;
  9. }
  10.  
  11. QWidget* SKGQueryDelegate::createEditor(QWidget *parent,
  12. const QStyleOptionViewItem & option ,
  13. const QModelIndex & index ) const
  14. {
  15. SKGTRACEIN(1, "SKGQueryDelegate::createEditor");
  16.  
  17. QTableWidgetItem* it_h=((QTableWidget*) this->parent())->horizontalHeaderItem(index.column());
  18. QString attname=it_h->data(Qt::UserRole).toString();
  19.  
  20. SKGPredicatCreator* editor=new SKGPredicatCreator(parent, document, attname, updateMode);
  21.  
  22. return editor;
  23. }
  24.  
  25. void SKGQueryDelegate::setEditorData ( QWidget * editor, const QModelIndex & index ) const
  26. {
  27. SKGTRACEIN(1, "SKGQueryDelegate::setEditorData");
  28. SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
  29. if (pred) {
  30. pred->setXmlDescription(index.model()->data(index, Qt::UserRole).toString());
  31. } else QItemDelegate::setEditorData (editor, index);
  32. }
  33.  
  34. void SKGQueryDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
  35. const QModelIndex &index) const
  36. {
  37. SKGTRACEIN(1, "SKGQueryDelegate::setModelData");
  38. SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
  39. if (pred && model) {
  40. QString xml=pred->xmlDescription();
  41. model->setData(index, pred->text(), Qt::DisplayRole);
  42. model->setData(index, xml, Qt::UserRole);
  43. } else QItemDelegate::setModelData (editor, model, index);
  44. }
To copy to clipboard, switch view to plain text mode 

using my own widget SKGPredicatCreator:
Qt Code:
  1. class SKGBANKGUI_EXPORT SKGPredicatCreator : public QWidget
  2. {
  3. Q_OBJECT
  4. Q_PROPERTY( QString test READ text USER true)
  5. Q_PROPERTY( QString xmlDescription READ xmlDescription WRITE setXmlDescription)
  6.  
  7. public:
  8. /**
  9.   * Default Constructor
  10.   * @param parent the parent
  11.   * @param document the document
  12.   * @param attribute name of the attribute
  13.   */
  14. explicit SKGPredicatCreator(QWidget *parent = 0, SKGDocument* document=NULL, const QString& attribute="", bool iSQL=false);
  15.  
  16. /**
  17.   * Default Destructor
  18.   */
  19. virtual ~SKGPredicatCreator();
  20.  
  21. /**
  22.   * Get text
  23.   * @return text
  24.   */
  25. virtual QString text();
  26.  
  27. /**
  28.   * Get Text from XML description
  29.   * @param iXML the description
  30.   */
  31. static QString getTextFromXml(const QString& iXML);
  32.  
  33. /**
  34.   * Get XML description
  35.   * @return description
  36.   */
  37. virtual QString xmlDescription();
  38.  
  39. /**
  40.   * Set XML description
  41.   * @param iText the description
  42.   */
  43. virtual void setXmlDescription(const QString& iXML);
  44. signals:
  45.  
  46.  
  47. public slots:
  48.  
  49.  
  50. private slots:
  51. void onOperatorChanged();
  52.  
  53. private:
  54. Q_DISABLE_COPY(SKGPredicatCreator);
  55. bool updateMode;
  56.  
  57. SKGComboBox* kOperator;
  58. QWidget* kValue1;
  59. QWidget* kValue2;
  60. };
To copy to clipboard, switch view to plain text mode 

It works fine, except for the following scenario:
1-double click on a cell ==> cell becomes editable (SKGPredicatCreator is created).
2-Enter values in custom widget SKGPredicatCreator (do not click enter)
3-Click on external button "Add"

Problem: Values entered in step 2 are not automatically validate when I do step 3 (focus on SKGPredicatCreator is lost).
It's not the case, if I use a std widget like QComboBox.

Why ? What I have to do to activate automatic validation ?