diff --git a/soft/thermostat/inc/mainwindow.h b/soft/thermostat/inc/mainwindow.h index 9895011..4c758e6 100644 --- a/soft/thermostat/inc/mainwindow.h +++ b/soft/thermostat/inc/mainwindow.h @@ -33,7 +33,7 @@ public: private: MQTTClient *m_mqtt; - QPushButton m_state_btn; + QPushButton *m_state_btn; QVector m_zones; QTimer *m_timer; BoostDlg *m_boost; diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index c19dcd0..72dbb3c 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -49,7 +49,7 @@ MainWindow::MainWindow(QWidget *parent) : */ QGridLayout *mainLayout = new QGridLayout; - m_state_btn.setText(tr("Auto")); + m_state_btn = new QPushButton("Auto"); QPushButton *menu_btn = new QPushButton(tr("Menu")); if (s->nbZones() < MAX_NB_ZONES) { @@ -61,7 +61,7 @@ MainWindow::MainWindow(QWidget *parent) : mainLayout->addWidget(menu_btn, 0, 2); mainLayout->addWidget(m_zones.at(2), 1, 0); mainLayout->addWidget(m_zones.at(3), 1, 1); - mainLayout->addWidget(&m_state_btn, 1, 2); + mainLayout->addWidget(m_state_btn, 1, 2); } update_state_btn(s->m_state); @@ -73,10 +73,10 @@ MainWindow::MainWindow(QWidget *parent) : font.setPointSize(12); font.setBold(true); menu_btn->setFont(font); - m_state_btn.setFont(font); + m_state_btn->setFont(font); menu_btn->setSizePolicy(*szPolicy); - m_state_btn.setSizePolicy(*szPolicy); + m_state_btn->setSizePolicy(*szPolicy); QWidget *mainWidget = new QWidget; mainWidget->setLayout(mainLayout); @@ -107,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, SIGNAL(setAllHeatersOn(bool)), m_mqtt, SLOT(allHeatersOn(bool))); connect(m_mqtt, SIGNAL(connected(void)), this, SLOT(apply_order_to_heaters(void))); - connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); + connect(m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); connect(menu_btn, SIGNAL(clicked()), this, SLOT(show_menu())); /* @@ -235,16 +235,16 @@ void MainWindow::update_state_btn(enum power_states st) { switch (st) { case OFF: - m_state_btn.setText(tr("Force off")); + m_state_btn->setText(tr("Force off")); break; case ON: - m_state_btn.setText(tr("Force on")); + m_state_btn->setText(tr("Force on")); break; case AUTO: - m_state_btn.setText(tr("Auto")); + m_state_btn->setText(tr("Auto")); break; default: - m_state_btn.setText(tr("Error")); + m_state_btn->setText(tr("Error")); break; } }