Hello!

this is the code, I wrote:

Qt Code:
  1. #include "widget.h"
  2.  
  3. Widget::Widget(QWidget *parent)
  4. : QWidget(parent)
  5. {
  6. this->setGeometry(30,30,800,750);
  7. rank = new QLineEdit("Enter the Rank", this);//rank->setGeometry(10,0,20,20);
  8. ok = new QPushButton("Ok", this); ok->setGeometry(150, 0,80,30);
  9. calculate = new QPushButton("calculate",this); calculate->setGeometry(250,0,80,30);
  10.  
  11. coppy = new QTableWidgetItem;
  12.  
  13. connect(ok,SIGNAL(clicked()),this,SLOT(ok_clicked()));
  14. connect(calculate,SIGNAL(clicked()),this,SLOT(calculate_clicked()));
  15. }
  16.  
  17. Widget::~Widget()
  18. {
  19.  
  20. }
  21.  
  22. void Widget::ok_clicked()
  23. {
  24.  
  25. rank_of_Matrix = rank->text().toDouble();
  26. tbl=new QTableWidget(rank_of_Matrix,rank_of_Matrix,this);
  27. tbl->setGeometry(20,50,770,250);
  28. tbl->show();
  29.  
  30. tbl->setItem(2,2,ptwi = new QTableWidgetItem(QString::number(40)));
  31.  
  32.  
  33. Action_toArray(); // wrote all information into Array A[i][j] and make 0 all elements equals to zero
  34.  
  35. }
  36.  
  37. void Widget::calculate_clicked()
  38. {
  39. tbl = new QTableWidget(rank_of_Matrix,rank_of_Matrix,this);
  40.  
  41. tbl ->setGeometry(20,350,770,250);
  42. tbl->setItem(2,2, coppy->clone());
  43. tbl ->show();
  44. }
  45.  
  46. void Widget::Action_toArray()
  47. {
  48.  
  49. A= new float* [rank_of_Matrix];
  50. for(int i=0;i<rank_of_Matrix;i++){
  51. A[i]=new float [rank_of_Matrix];
  52. }
  53.  
  54. for(int i=0;i<rank_of_Matrix;i++){
  55. for(int j=0;j<rank_of_Matrix;j++){
  56. //wrote into Array from QTableWidget
  57. A[i][j] = tbl->item(i,j)->data(Qt::DisplayRole).toFloat();
  58. }
  59. }
  60.  
  61. //make all elements equals to 2
  62. for(int i=0;i<rank_of_Matrix;i++){
  63. for(int j=0;j<rank_of_Matrix;j++){
  64. if(A[i][j]==2){
  65. A[i][j]=0;
  66. }
  67. }
  68. }
  69. }
To copy to clipboard, switch view to plain text mode 

My question is: how to write changed Array into Table2 after clicking button "Calculate"? Do I get it right that I need to convert float into QTableWidgetItem and then using command tbl->setItem(rank_of_Matrix,rank_of_Matrix, coppy->clone()); in loop write it into Table?

Thank you in advance!