hello.
I have access to a model in a custom delegate.
I tryed to change some values in this model but when I read data from the model the data are always the same.
I tryed to emit dataChange, but nothing.

this is the code

Qt Code:
  1. bool CustomItemDelegate::editorEvent(QEvent *event,
  2. const QStyleOptionViewItem &option,
  3. const QModelIndex &index)
  4. {
  5. const QSortFilterProxyModel* modelx =
  6. static_cast<const QSortFilterProxyModel*>(index.model());
  7.  
  8. QDesignerWidgetBoxInterface::Widget widget =((WidgetBoxCategoryModel*)modelx->sourceModel())->widgetAt(index);
  9. ((WidgetBoxCategoryModel*)modelx->sourceModel())->refresh();
  10.  
  11. m_strName = widget.name();
  12. QRect buttonRect( option.rect);
  13. buttonRect.setWidth( 30);
  14.  
  15.  
  16. if(widget.getFunction() == QDesignerWidgetBoxInterface::Widget::Creator)
  17. {
  18. if( event->type() == QEvent::MouseButtonPress){
  19. }
  20. else if( event->type() == QEvent::MouseButtonRelease) {
  21.  
  22. if(m_pPrecedentPressedState != NULL && m_pPrecedentPressedState != &m_pressedState)
  23. *m_pPrecedentPressedState = QStyle::State_Raised;
  24.  
  25. widget.setName("luigi");//CHANGE THE MODEL !!!!!!!
  26.  
  27. m_pressedState = *widget.getState();
  28. if(m_pressedState == QStyle::State_Sunken )
  29. m_pressedState = QStyle::State_Raised ;
  30. else
  31. { m_pressedState = QStyle::State_Sunken;
  32. }
  33. m_pPrecedentPressedState = &m_pressedState;
  34. m_strPressedName = widget.name();
  35. }
  36. }
  37.  
  38. if( event->type() == QEvent::MouseButtonRelease) {
  39.  
  40. emit buttonClicked( index);
  41. emit pressDel(m_strName);
  42. }
  43. ((WidgetBoxCategoryModel*)modelx->sourceModel())->ChangeData();
  44. return true;
  45.  
  46. }
To copy to clipboard, switch view to plain text mode 

((WidgetBoxCategoryModel*)modelx->sourceModel())->ChangeData();
WidgetBoxCategoryModel is a custom model with into this function:

Qt Code:
  1. void WidgetBoxCategoryModel::ChangeData()
  2. {
  3.  
  4. dataChanged(index(0,0),index(2,2));
  5. emit dataChanged(index(0,0),index(2,2));
  6. }
To copy to clipboard, switch view to plain text mode