title: Qt checking the state of multiple buttons
body: <p>I am using a StackedLayout and Buttons to switch between screens. I have a separate style for if a button is checked or not. I am also using keyPressEvent to switch between stacks instead of clicking on a button to switch.</p>
  
  <p>When I use the keyPress event, I can switch between stacks, but the buttons don't change from unchecked to checked.</p>
  
  <p>I have 4 buttons and for each I wrote methods to see if the button is checked or not, like so:</p>
  
  <pre><code>bool MainWindow::dashBoardButton_isChecked() {
      if(ui-&gt;dashBoardButton-&gt;isChecked()) {
          return true;
      } else {
          return false;
      };
  
      return false;
  };
  </code></pre>
  
  <p>and when I switch between stacks, I use this method:</p>
  
  <pre><code>void MainWindow::on_dashBoardButton_clicked() {
      ui-&gt;mainStack-&gt;setCurrentIndex(0);
  
      if(!dashBoardButton_isChecked()) {
          ui-&gt;dashBoardButton-&gt;setChecked(true);
      };
  
  };
  </code></pre>
  
  <p>I do this 4 times for each button/stack.  This seems to me to be a little repetitive. Is there some way I could shorten the code, and maybe instead of having 4 very similar methods, have one method that instead?</p>