i have uses another way because really i don't know, how i can catch "the opening and closing of editor in Qstyleditemdelegate, like what you said

her is my code
Qt Code:
  1. #include "dialog.h"
  2.  
  3. Dialog::Dialog(QWidget *parent)
  4. : QWidget(parent)
  5. {
  6. layoutPrincipale = new QVBoxLayout(this);
  7. QPushButton *button = new QPushButton("Clear",this);
  8. tableau = new MonTableauWidget(this);
  9. tableau->setRowCount(1);
  10. tableau->setColumnCount(4) ;
  11. tableau->setCurrentIndex(tableau->model()->index(0,0,QModelIndex()));
  12.  
  13. //tableau->setCurrentIndex();
  14. // QKeyEvent event(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier);
  15.  
  16.  
  17. QStringList list ;
  18. list << "Désignation" << "Qte" << "Prix/U" << "Total";
  19. tableau->setHorizontalHeaderLabels(list);
  20. tableau->setCurrentCell(0,0);
  21. layoutPrincipale->addWidget(tableau);
  22. layoutPrincipale->addWidget(button);
  23. setLayout(layoutPrincipale);
  24. //connect(tableau,SIGNAL(cellChanged(int,int)),this,SLOT(addrow(int,int))) ;
  25. connect(button,SIGNAL(clicked()),tableau,SLOT(clear()));
  26. connect(tableau,SIGNAL(itemSelectionChanged()),this,SLOT(newfunction()));
  27.  
  28. }
  29.  
  30. Dialog::~Dialog()
  31. {
  32.  
  33. }
  34.  
  35. void Dialog::addrow(int row, int col)
  36. {
  37. if(col == 0)
  38. tableau->insertRow(tableau->rowCount());
  39. }
  40.  
  41. void Dialog::newRecod(QKeyEvent *record)
  42. {
  43.  
  44. }
  45.  
  46. void Dialog::newfunction()
  47. {
  48. item->setIcon( *(new QIcon("imgs/editIcon.png")));
  49. tableau->setVerticalHeaderItem(0,item);
  50. for (int rowToDelete=0; rowToDelete < tableau->rowCount(); ++rowToDelete)
  51. {
  52. if(rowToDelete != 0)
  53. tableau->takeVerticalHeaderItem(rowToDelete);
  54. }
  55.  
  56. }
To copy to clipboard, switch view to plain text mode