Hello,
As the title is saying , I am trying to put the result of a user input , in a QTableWidget, and take this QTableWidget to fillin an array.
I have read the documentation but infortunetly I can not do it .
Here is the code:
Qt Code:
  1. //the header
  2. #ifndef FENPRINCIPALE_H
  3. #define FENPRINCIPALE_H
  4. #include <QtGui>
  5. #include <vector>
  6. class FenPrincipale : public QWidget
  7. {
  8. Q_OBJECT
  9. public:
  10. FenPrincipale();
  11. bool M[2][2];
  12. QTableWidgetItem * element;
  13. private slots:
  14. private:
  15. QTableWidget* tableWidget;
  16.  
  17.  
  18. };
  19. #endif
  20.  
  21.  
  22.  
  23. //FenPrincipale.cpp
  24.  
  25.  
  26.  
  27. #include "qDebug.h"
  28. #include "FenPrincipale.h"
  29.  
  30.  
  31. FenPrincipale::FenPrincipale()
  32. {
  33. int o,p;
  34.  
  35. tableWidget = new QTableWidget(2,2,this);
  36. element = new QTableWidgetItem (1000);
  37. for (o=0; o<2; o++)
  38. {
  39. for (p=0; p<2; p++)
  40. {
  41. (M[o][p])=false;
  42.  
  43. }
  44. }
  45.  
  46. for (o=0; o<2; o++)
  47. {
  48. for (p=0; p<2; p++)
  49. {
  50. element=(tableWidget->itemAt((o+1),(p+1)));
  51. if ((element->toString)="1")
  52. {
  53. M[o][p]=true;
  54. }
  55. else
  56. {
  57. M[o][p]=false;
  58. }
  59. }
  60. }
  61.  
  62. }
  63.  
  64.  
  65. //main.cpp
  66.  
  67.  
  68. #include <QApplication>
  69. #include "FenPrincipale.h"
  70. int main(int argc, char* argv[])
  71. {
  72. QApplication app(argc, argv);
  73.  
  74. FenPrincipale fenetre;
  75. fenetre.show();
  76. return app.exec();
  77. }
To copy to clipboard, switch view to plain text mode 
Thank you very much for the attention given to this message.