Thanks for the reply, I understand everything you wrote (it makes perfect sense), I'm just a little confused as to why I would need it.
I understand classes and objects and I've worked a bit with polymorphism and inherited classes, though it's been a few years and I may need to brush up on that a little. I think I just need a better understanding of this GUI stuff in general.
A few questions.
1. Under the design tab I can drag different button's/input boxes/display boxes onto the UI. Now if I'm understanding this correctly, whenever I drag an object, for example lets say I drag a push button into the UI box, that button is now an object(instantiation of button class) within the UI object. So in essence, would it be safe to say the push button is now a member of the UI class?
2. Is the purpose of the "->" much like the purpose of the "."
for example, typing
ui->
brings up a list of all the members of ui. For instance, if I drag and drop a push button onto the UI, it would look like
ui->pushButton
If I drag 2 pushButtons and a label onto the UI it would look like
1 2 3
|
ui->pushButton1
pushButton2
label
|
3. Why would I need to be able to change the state of the button for tic tac toe? Shouldn't it just be a one time thing? Once an X or O is displayed in a box, I see no reason why that box would need to be changed to the opposite. Shouldn't I just display X or O depending on which letter the user is and then clear the board at the end of the game?
4. How do I display a jpg image to a graphics box? The code I posted does nothing. I have 9 graphics display widgets on my UI, I also have 9 Push buttons off to the side. I want to make it so that when the first(top left) push button is clicked, a jpg image will display to the first graphics box. I created a function called buttonClickedHandler1() that controls what happens whenever the first push button is clicked. The code I have literally does nothing
1 2 3 4 5
|
void Tic_Tac_Toe::buttonClickHandler()
{
ui->graphicsBox1->setBackgroundBrush(QPixmap("C:/Users/Richard/PicturesProgramming Images/Google-Chrome-Logo.jpg"));
}
|
if I change the command to
ui->graphicsBox1->close();
then the first graphics display widget disappears, so I at least know I'm accessing the right object. If I type
ui->graphicsBox2->close();
then the second graphics display widget disappears.
Am I using the wrong function? Am I passing the jpg image wrong? Basically, how do I display an image to graphicsBox1?