Hi All,

I have made a QTableView which has 200 rows and 4 columns, when the user press the enter Key it opens a new QDialog which has 4 QlineEdits and these QlineEdits values has to be displayed in QTableView. here is the code snippet for QDialog

tooladddialog.cpp
Qt Code:
  1. QString ToolAddDialog::toolgetValues()
  2. {
  3. QString line;
  4.  
  5. toolnolineEdit->selectAll();
  6. line.append( toolnolineEdit->text() );
  7. line.append( " " );
  8.  
  9. diameterlineEdit->selectAll();
  10. line.append( diameterlineEdit->text() );
  11. line.append( " " );
  12.  
  13. lengthlineEdit->selectAll();
  14. line.append( lengthlineEdit->text() );
  15. line.append( " " );
  16.  
  17. unitslineEdit->selectAll();
  18. line.append( unitslineEdit->text() );
  19. return line;
  20. }
To copy to clipboard, switch view to plain text mode 

tooform.cpp
Qt Code:
  1. void ToolForm::keyPressEvent( QKeyEvent *event )
  2. {
  3. qDebug( "Key Press Event" );
  4. switch ( event->key() )
  5. {
  6. case Qt::Key_Return: //Mapped with Enter Key
  7. add_tool();
  8.  
  9. break;
  10.  
  11. case Qt::Key_Escape: //Mapped with Cancel key
  12. close();
  13. break;
  14.  
  15. default:
  16. QWidget::keyPressEvent(event);
  17. }
  18. }
  19.  
  20. void ToolForm::add_tool()
  21. {
  22. ToolAddDialog tooladddialog;
  23.  
  24. if( tooladddialog.exec())
  25. {
  26. QString str = tooladddialog.toolgetValues();
  27. QStringList fields = str.split(" ");
  28.  
  29. if (!tooltableView)
  30. return;
  31. // now values should be added to the QTableView
  32. }
  33. }
To copy to clipboard, switch view to plain text mode 

How to resolve this issue. if any snippet would be advantage.