change label text on button press

This commit is contained in:
josh committed 2015-03-25 19:46:10 -04:00
1 parent 64e3d89818
commit e5c7d48eca
2 files changed
+11 -5

No files matched your search

+7 -5
View File
@@ -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");
}
+4
View File
@@ -14,6 +14,10 @@ public:
private slots:
void handleButton();
private:
QPushButton * m_button;
QLabel * m_label;
};
#endif