OK, I got it to compile but when i press execute the LCDNumber thing doesn't change.
here is the cofr
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
#include <QLCDNumber>
#include <QHBoxLayout>
#include <QVBoxLayout>
public:
{
layout->addWidget(num1);
layout->addWidget(num2);
layout->addWidget(answer);
mainLayout->addLayout(layout);
mainLayout->addWidget(equal);
QObject::connect(equal,
SIGNAL(clicked
()), answer,
SLOT(minus
()));
}
public slots:
void minus(){
answer->display(num1->value()-num2->value());
}
private:
};
int main(int argc, char *argv[])
{
calculator w;
w.show();
return app.exec();
}
#include <QApplication>
#include <QPushButton>
#include <QLabel>
#include <QSpinBox>
#include <QLCDNumber>
#include <QHBoxLayout>
#include <QVBoxLayout>
class calculator : public QWidget{
public:
calculator(QWidget *parent = 0) : QWidget(parent)
{
equal = new QPushButton("Execute");
num1 = new QSpinBox;
num2 = new QSpinBox;
answer = new QLCDNumber;
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(num1);
layout->addWidget(num2);
layout->addWidget(answer);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addLayout(layout);
mainLayout->addWidget(equal);
QObject::connect(equal, SIGNAL(clicked()), answer, SLOT(minus()));
}
public slots:
void minus(){
answer->display(num1->value()-num2->value());
}
private:
QPushButton *equal;
QSpinBox *num1;
QSpinBox *num2;
QLCDNumber *answer;
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
calculator w;
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks