So the thing is, that my function that is spupposed to dynamically create a board of empty buttons and then save each one of them in an array of buttons isnt working;
To be precise, it is supposed to create 2 types of board: 3on3 and 20on20;
3on3 is working but 20on20 isnt and i dont know why becouse the code is the same in both variables;

Here is my code:

TicTacToe.h

Qt Code:
  1. #ifndef RYSUJ_PLANSZE_H
  2. #define RYSUJ_PLANSZE_H
  3.  
  4. #include <QWidget>
  5.  
  6. class TicTacToe :public QWidget
  7. {
  8. public:
  9. void create(); //input od gracza czy mapa 3na3 czy 5na5
  10. TicTacToe();
  11. int height; //rz?dy
  12. int width; //kolumny
  13. int winning_length;
  14. bool button_array[];
  15. };
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. #endif // RYSUJ_PLANSZE_H
To copy to clipboard, switch view to plain text mode 

TicTacToe.cpp

Qt Code:
  1. #include "TicTacToe.h"
  2. #include <QApplication>
  3. #include <QLabel>
  4. #include <QtWidgets>
  5. #include <QtCore>
  6. #include <QMessageBox>
  7. #include <QDialog>
  8. #include <QGridLayout>
  9.  
  10.  
  11.  
  12. QMessageBox::StandardButton reply;
  13.  
  14.  
  15.  
  16. TicTacToe::TicTacToe()
  17. {
  18. reply = QMessageBox::question(this, "Question", "If You want to play 3on3 map click 'Yes', "
  19. "if You want to play 5on5 map click 'No'");
  20. }
  21.  
  22. void TicTacToe::create()
  23. {
  24.  
  25. QWidget *window = new QWidget;
  26. QGridLayout *layout = new QGridLayout;
  27. window->setWindowTitle("Tic-Tac-Toe");
  28. //-------------------------------------------------------------------------------------------------------
  29.  
  30. if(reply==QMessageBox::Yes)
  31. {
  32. int w = 3;
  33. int h = 3;
  34.  
  35. TicTacToe::width = w;
  36. TicTacToe::height = h;
  37. TicTacToe::winning_length = 3;
  38.  
  39. for(int i = 0; i<w; i++)
  40. {
  41. for(int j = 0; j<h; j++)
  42. {
  43. QPushButton *button[i][j];
  44. button[i][j] = new QPushButton();
  45. layout->addWidget(button[i][j], i, j);
  46. button[i][j]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  47. button_array[i,j] = false;
  48.  
  49. }
  50. }
  51. }
  52. else
  53. {
  54. int w = 20;
  55. int h = 20;
  56.  
  57. TicTacToe::width = w;
  58. TicTacToe::height = h;
  59. TicTacToe::winning_length = 5;
  60.  
  61. for(int i = 0; i<h; i++)
  62. {
  63. for(int j = 0; j<w; j++)
  64. {
  65. QPushButton *button[i][j];
  66. button[i][j] = new QPushButton();
  67. layout->addWidget(button[i][j], i, j);
  68. button[i][j]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  69. button_array[i,j] = false;
  70. }
  71. }
  72. }
  73. //---------------------------------------------------------------------------------------------------
  74. window->setLayout(layout);
  75. window->show();
  76. }
To copy to clipboard, switch view to plain text mode 

main.cpp

Qt Code:
  1. #include "TicTacToe.h"
  2. #include <QApplication>
  3. #include <QLabel>
  4. #include <QtWidgets>
  5. #include <QtCore>
  6. #include <QMessageBox>
  7. #include <QDialog>
  8. #include <QGridLayout>
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. QApplication app(argc, argv);
  13. //--------------------------------------------------------------
  14.  
  15.  
  16. TicTacToe *R = new TicTacToe;
  17. R->create();
  18.  
  19.  
  20.  
  21. //--------------------------------------------------------------
  22. return app.exec();
  23. }
To copy to clipboard, switch view to plain text mode 

And my question rn is --> What i going on? The error i get is --> The program has unexpectedly finished