OK, here is the entire code,
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
#include <QLCDNumber>
#include <QHBoxLayout>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
int calc1, calc2;
QObject::connect(num1,
SIGNAL(valueChanged
(calc1
)),
this,
SLOT(setValue
(calc1
)));
QObject::connect(num2,
SIGNAL(valueChanged
(calc2
)),
this,
SLOT(setValue
(calc2
)));
QObject::connect(equal,
SIGNAL(clicked
()), show,
SLOT(setValue
(calc1
-calc2
)));
layout->addWidget(num1);
layout->addWidget(minus);
layout->addWidget(num2);
layout->addWidget(show);
mainLayout->addLayout(layout);
mainLayout->addWidget(equal);
return app.exec();
}
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
#include <QLCDNumber>
#include <QHBoxLayout>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *minus = new QLabel("-");
QPushButton *equal = new QPushButton("Execute");
QSpinBox *num1 = new QSpinBox;
QSpinBox *num2 = new QSpinBox;
QLCDNumber *show = new QLCDNumber(3);
int calc1, calc2;
QObject::connect(num1, SIGNAL(valueChanged(calc1)), this, SLOT(setValue(calc1)));
QObject::connect(num2, SIGNAL(valueChanged(calc2)), this, SLOT(setValue(calc2)));
QObject::connect(equal, SIGNAL(clicked()), show, SLOT(setValue(calc1-calc2)));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(num1);
layout->addWidget(minus);
layout->addWidget(num2);
layout->addWidget(show);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(layout);
mainLayout->addWidget(equal);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
and here are the errors I receive.
|19|error: invalid use of `this' in non-member function|
|20|error: invalid use of `this' in non-member function|
|19|error: invalid use of `this' in non-member function|
|20|error: invalid use of `this' in non-member function|
To copy to clipboard, switch view to plain text mode
Bookmarks