[SOLVED]Trying to use a bool when pressing a button
-
@void streamwindow::on_pushButton_clicked()
{
if(streamsite == false){
ui->label->setText("Azubu.tv");
streamsite = true;
}
if(streamsite == true){
ui->label->setText("Twitch.tv");
streamsite = false;
}
}@So, when I run this and press the button it only stays on twitch.tv and I'm not really sure why. I've tried to switch around the code and I even tried it with a string, but that didn't change anything.
-
Hi,
@
if(streamsite == false){
ui->label->setText("Azubu.tv");
streamsite = true;
}
here's your problem, if streamsite was false, it now is true thus:if(streamsite == true){ ui->label->setText("Twitch.tv"); streamsite = false; }
@
just replace the second if by else and you should be good to go
-
Thank you for your help! :)