Имею такое описание класса:
class CalcDialog : public QDialog {
Q_OBJECT;
public:
CalcDialog(QWidget *parent = 0);
signals:
void numPush(const int num);
void actionPush(act c);
void pointPush();
void resPush();
void sqrPush();
private slots:
void calc();
void editLine(int i);
void editLine(float f);
void setAction(act c);
private:
QLineEdit *editStr;
QPushButton *buttonNums[10];
ActionButton *buttonPlus;
ActionButton *buttonMinus;
ActionButton *buttonMul;
ActionButton *buttonDiv;
ActionButton *buttonSquare;
QPushButton *buttonRes;
QPushButton *buttonPoint;
};
и реализацию:
CalcDialog::CalcDialog(QWidget *parent) : QDialog(parent) {
editStr = new QLineEdit;
for(int i = 0;i<10;i++) buttonNums[i] = new QPushButton(QString::number(i));
buttonPoint = new QPushButton(".");
buttonPlus = new ActionButton(ADD,"+");
buttonMinus = new ActionButton(SUB,"-");
buttonMul = new ActionButton(MUL,"*");
buttonDiv = new ActionButton(DIV,"/");
buttonSquare = new ActionButton(SQR,"X2");
buttonRes = new QPushButton("=");
for(int i = 0;i<10;i++) connect(buttonNums[i],SIGNAL(clicked()),this,SLOT(editLine(i)));
connect(buttonPoint,SIGNAL(clicked()),this,SLOT(editLine(float f)));
connect(buttonPlus,SIGNAL(clicked()),this,SLOT(setAction(buttonPlus->getAction())));
connect(buttonMinus,SIGNAL(clicked()),this,SLOT(setAction(buttonMinus->getAction())));
connect(buttonMul,SIGNAL(clicked()),this,SLOT(setAction(buttonMul->getAction())));
connect(buttonDiv,SIGNAL(clicked()),this,SLOT(setAction(buttonDiv->getAction())));
connect(buttonSquare,SIGNAL(clicked()),this,SLOT(setAction(buttonSquare->getAction())));
connect(buttonRes,SIGNAL(clicked()),this,SLOT(calc()));
}
На что получаю при сборке:
C:/PROJECTS/Qt/WindowApplication/calculus/debug/moc_calc_dialog.cpp:85: undefined reference to `CalcDialog::editLine(int)'
C:/PROJECTS/Qt/WindowApplication/calculus/debug/moc_calc_dialog.cpp:86: undefined reference to `CalcDialog::editLine(float)'
C:/PROJECTS/Qt/WindowApplication/calculus/debug/moc_calc_dialog.cpp:87: undefined reference to `CalcDialog::setAction(act)'
C:/PROJECTS/Qt/WindowApplication/calculus/debug/moc_calc_dialog.cpp:84: undefined reference to `CalcDialog::calc()'
в мок файлике примерно такое:
int CalcDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDialog::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: numPush((*reinterpret_cast< const int(*)>(_a[1]))); break;
case 1: actionPush((*reinterpret_cast< act(*)>(_a[1]))); break;
case 2: pointPush(); break;
case 3: resPush(); break;
case 4: sqrPush(); break;
case 5: calc(); break;
case 6: editLine((*reinterpret_cast< int(*)>(_a[1]))); break;
case 7: editLine((*reinterpret_cast< float(*)>(_a[1]))); break;
case 8: setAction((*reinterpret_cast< act(*)>(_a[1]))); break;
default: ;
}
_id -= 9;
}
return _id;
}
Делал в QtCreator'e