Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

Can't Connect a QPushButton to a QLable

$
0
0
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

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>