Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Trying to use a bool when pressing a button
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Trying to use a bool when pressing a button

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 817 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Ducking Ferp
    wrote on last edited by
    #1

    @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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Ducking Ferp
        wrote on last edited by
        #3

        Thank you for your help! :)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved