change label text on button press
This commit is contained in:
parent
64e3d89818
commit
e5c7d48eca
@ -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");
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ public:
|
||||
|
||||
private slots:
|
||||
void handleButton();
|
||||
|
||||
private:
|
||||
QPushButton * m_button;
|
||||
QLabel * m_label;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user