Well, try a debugger and check where it crashes.
Ginsengelf
Well, try a debugger and check where it crashes.
Ginsengelf
For one thing, TicTacToe is derived from QWidget, but it does not contain the Q_OBJECT macro in the class documentation.
It would probably be a good idea to study some of the many Qt examples and tutorials. Your code is full of mistakes and very strange things which don't follow the usual Qt app development conventions.
I have no idea what you think this is supposed to do (or mean). It declares a variable named "button" that is a two-dimensional array of pointers to QPushButton, where the first dimension has size "i" and the second has size "j". As soon as the loop over j exits, this array goes out of scope and is destroyed.QPushButton *button[i][j];
You also try to assign values to button_array[i][j], but button_array is never initialized.
To add to what Ginsengelf said, first learn some C++, and then learn how to use the debugger.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
There are soooo many things wrong with this code...
But what catches the eye the most is your for loop where you create the buttons.
I am actually surprised the compiler is not complaining, I'd expect ' QPushButton *button[i][j];' to not be legal, since to my knowledge i and j in an array decleratio must be constants.
Even if I am wrong, this line creates the first time an array of 0 x 0 elements.
But you access the first element (element 0) - which should crash.
Then, for each iteration of the loop you redefine the array with new dimensions.
Ha, beat to it by d_tranz:-)
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Yes, I would be surprised if the button[i][j] statement compiles, but if this is the real code maybe it does. I always thought array dimensions had to be constants, too, but C++ is changing faster than I can keep up with.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks