diff --git a/src/MyWindow.cc b/src/MyWindow.cc index 289e890..886ef1b 100644 --- a/src/MyWindow.cc +++ b/src/MyWindow.cc @@ -8,17 +8,19 @@ MyWindow::MyWindow(QWidget * parent) { QHBoxLayout * layout = new QHBoxLayout(); - QPushButton * button = new QPushButton("Press me"); - layout->addWidget(button); + m_button = new QPushButton("Press me"); + layout->addWidget(m_button); - QLabel * label = new QLabel("Label"); - layout->addWidget(label); + m_label = new QLabel("Label"); + layout->addWidget(m_label); setLayout(layout); setWindowTitle("My Qt Application!"); + + connect(m_button, SIGNAL(clicked()), this, SLOT(handleButton())); } void MyWindow::handleButton() { - cerr << "got a button press" << endl; + m_label->setText("The button was pressed"); } diff --git a/src/MyWindow.h b/src/MyWindow.h index 213cf8c..1fdfe3f 100644 --- a/src/MyWindow.h +++ b/src/MyWindow.h @@ -14,6 +14,10 @@ public: private slots: void handleButton(); + +private: + QPushButton * m_button; + QLabel * m_label; }; #endif