Hello, I am a beginner in the Qt world. I have written a very simple program. In the program I have a button and a label, the label is set to the number 0. I want when I push the button the label to be reset to another number. I have written the following code
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QGridLayout>
void change( QLabel *label )
{
label->setText(QString::number('32'));
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window = new QWidget;
QGridLayout *layout = new QGridLayout(window);
QPushButton *button = new QPushButton("+");
QLabel *value = new QLabel("0");
layout->addWidget(button);
layout->addWidget(value);
QObject::connect(button, SIGNAL(clicked()), value, SLOT(change(label)));
window->resize(200,200);
window->setWindowTitle("Project");
window->show();
return a.exec();
}
When I run the code and press the push button nothing happens. Any suggestions how I fix that code. Please keep it simple as possible nothing fancy.
Thank You
↧