Qt Code:
  1. #include <QApplication>
  2. #include <QPushButton>
  3. #include <QLabel>
  4. #include <QSpinBox>
  5. #include <QLCDNumber>
  6. #include <QHBoxLayout>
  7. #include <QVBoxLayout>
  8.  
  9. class Calculator : public QWidget {
  10. Q_OBJECT
  11. public:
  12. Calculator(QWidget *parent = 0) : QWidget(parent){
  13. minus = new QLabel("-");
  14. equal = new QPushButton("&Execute");
  15. num1 = new QSpinBox;
  16. num2 = new QSpinBox;
  17. answer = new QLCDNumber(3);
  18.  
  19. QHBoxLayout *layout = new QHBoxLayout;
  20. layout->addWidget(num1);
  21. layout->addWidget(minus);
  22. layout->addWidget(num2);
  23. layout->addWidget(answer);
  24. QHBoxLayout *buttons = new QHBoxLayout;
  25. buttons->addStretch();
  26. buttons->addWidget(equal);
  27. buttons->addStretch();
  28. QVBoxLayout *mainLayout = new QVBoxLayout(this);
  29. mainLayout->addLayout(layout);
  30. mainLayout->addLayout(buttons);
  31. QObject::connect(equal, SIGNAL(clicked()), answer, SLOT(calculate()));
  32. }
  33. public slots:
  34. void calculate() {
  35. answer->display(num1->value()-num2->value());
  36. disconnect();
  37. }
  38. private:
  39. QLabel *minus;
  40. QPushButton *equal;
  41. QPushButton *help;
  42. QSpinBox *num1;
  43. QSpinBox *num2;
  44. QLCDNumber *answer;
  45. };
  46.  
  47. int main(int argc, char **argv){
  48. QApplication app(argc, argv);
  49. Calculator w;
  50. w.show();
  51. return app.exec();
  52. }
To copy to clipboard, switch view to plain text mode 
When the compiler is linking to the .exe it gives me this error.
Qt Code:
  1. C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\stl_algobase.h:(.text$_ZN10CalculatorD1Ev[Calculator::~Calculator()]+0xb)||undefined reference to `vtable for Calculator'|
To copy to clipboard, switch view to plain text mode 

Thank you in advance.