Hi!
I'm trying to develop a simple calculator. I'm using Qt Creator. I've already designed a form, but now I have a problem with slot. It calls, when i push the button with digit and adds the digit to lcd. I think everything is ok, but i get compiler's errors. Here is the source code:
//calc.h
#ifndef CALC_H
#define CALC_H
#include <QtGui/QDialog>
namespace Ui
{
class Calc;
}
{
Q_OBJECT
public:
~Calc();
slots:
void setVal(const int &val);
private:
Ui::Calc *ui;
};
#endif // CALC_H
//calc.h
#ifndef CALC_H
#define CALC_H
#include <QtGui/QDialog>
namespace Ui
{
class Calc;
}
class Calc : public QDialog
{
Q_OBJECT
public:
Calc(QWidget *parent = 0);
~Calc();
slots:
void setVal(const int &val);
private:
Ui::Calc *ui;
};
#endif // CALC_H
To copy to clipboard, switch view to plain text mode
//calc.cpp
#include "calc.h"
#include "ui_calc.h"
: QDialog(parent
), ui
(new Ui
::Calc) {
ui->setupUi(this);
}
Calc::~Calc()
{
delete ui;
}
void Calc::setVal(const int &val){
lcdNumber-> intValue*=10;
lcdNumber -> intValue+=val;
}
//calc.cpp
#include "calc.h"
#include "ui_calc.h"
Calc::Calc(QWidget *parent)
: QDialog(parent), ui(new Ui::Calc)
{
ui->setupUi(this);
}
Calc::~Calc()
{
delete ui;
}
void Calc::setVal(const int &val){
lcdNumber-> intValue*=10;
lcdNumber -> intValue+=val;
}
To copy to clipboard, switch view to plain text mode
And these are the errors:
calc.h:16: error: expected primary-expression before ‘void’
calc.h:16: error: ISO C++ forbids declaration of ‘type name’ with no type
calc.h:16: error: expected ‘;’ before ‘void’
calc.cpp:11: error: no ‘void Calc::setVal(const int&)’ member function declared in class ‘Calc’
Please help me
Regards
Stefek
Bookmarks