You realize that this code is not optimal? Much better would be such as :
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. MainWindow::~MainWindow()
  12. {
  13. delete ui;
  14. }
  15.  
  16. void MainWindow::pumpLabelOnOff(QLabel *pl)
  17. {
  18. if( pl->text() == "Pump On")
  19. pl->setText("Pump Off");
  20. else {
  21. pl->setText("Pump On");
  22. }
  23. }
  24.  
  25. void MainWindow::on_Pump1_clicked()
  26. {
  27. pumpLabelOnOff(ui->Pump1Label);
  28. }
  29.  
  30. void MainWindow::on_Pump2_clicked()
  31. {
  32. pumpLabelOnOff(ui->Pump2Label);
  33. }
  34.  
  35. void MainWindow::on_Pump3_clicked()
  36. {
  37. pumpLabelOnOff(ui->Pump3Label);
  38. }
To copy to clipboard, switch view to plain text mode