Im trying to create a keypad widget. I am having problems with the button events. I keep getting the following errors:

undefined references to `vtable for Keypad' follow CarPuta keypad.h line 20
undefined reference to `Keypad::staticMetaObject' CarPuta keypad.h line 21
undefined reference to `vtable for Keypad' CarPuta keypad.h line 20
undefined reference to `vtable for Keypad' CarPuta keypad.h line 33

This is my code

Qt Code:
  1. #ifndef KEYPAD_H_
  2. #define KEYPAD_H_
  3.  
  4. #include <QWidget>
  5. #include <QApplication>
  6. #include <QFont>
  7. #include <QPushButton>
  8. #include <QMainWindow>
  9. #include <QLabel>
  10. #include <QScrollArea>
  11. #include <QMouseEvent>
  12. #include <iostream>
  13. #include <X11/Xlib.h>
  14. #include <QLineEdit>
  15. #include <iostream>
  16. #include <QObject>
  17.  
  18. class Keypad : public QWidget
  19. {
  20. Q_OBJECT
  21. public slots:
  22. void button_1_clicked();
  23. public:
  24. Keypad(QWidget *parent = 0);
  25. };
  26.  
  27. void Keypad::button_1_clicked()
  28. {
  29. std::cout << "Clicked";
  30. }
  31.  
  32. Keypad::Keypad(QWidget *parent) : QWidget(parent)
  33. {
  34.  
  35. //get the screen resolution
  36. Display* dpy = XOpenDisplay(0);
  37. int xscreenres = DisplayWidth(dpy, DefaultScreen(dpy));
  38. int yscreenres = DisplayHeight(dpy, DefaultScreen(dpy));
  39.  
  40. //the text box
  41. QLineEdit *password = new QLineEdit(this);
  42. password->setGeometry(((xscreenres/2) - 190), ((yscreenres/2) - 270), 380, 80);
  43. password->setAlignment(Qt::AlignHCenter);
  44. password->setMaxLength(8);
  45. password->setEnabled(false);
  46. password->setEchoMode(QLineEdit::Password);
  47.  
  48. QPushButton *Button_1 = new QPushButton(tr("1"), this);
  49. Button_1->setGeometry((xscreenres/2) - 190, (yscreenres/2) - 125, 120, 120);
  50. Button_1->setFont(QFont("Times", 40, QFont::Bold));
  51. connect(Button_1, SIGNAL(clicked()), this, SLOT(button_1_clicked()));
  52.  
  53. QPushButton *Button_2 = new QPushButton(tr("2"), this);
  54. Button_2->setGeometry((xscreenres/2) - 60, (yscreenres/2) - 125, 120, 120);
  55. Button_2->setFont(QFont("Times", 40, QFont::Bold));
  56.  
  57. QPushButton *Button_3 = new QPushButton(tr("3"), this);
  58. Button_3->setGeometry((xscreenres/2) + 70, (yscreenres/2) - 125, 120, 120);
  59. Button_3->setFont(QFont("Times", 40, QFont::Bold));
  60.  
  61. QPushButton *Button_4 = new QPushButton(tr("4"), this);
  62. Button_4->setGeometry((xscreenres/2) - 190, (yscreenres/2) + 5, 120, 120);
  63. Button_4->setFont(QFont("Times", 40, QFont::Bold));
  64.  
  65. QPushButton *Button_5 = new QPushButton(tr("5"), this);
  66. Button_5->setGeometry((xscreenres/2) - 60, (yscreenres/2) + 5, 120, 120);
  67. Button_5->setFont(QFont("Times", 40, QFont::Bold));
  68.  
  69. QPushButton *Button_6 = new QPushButton(tr("6"), this);
  70. Button_6->setGeometry((xscreenres/2) + 70, (yscreenres/2) + 5, 120, 120);
  71. Button_6->setFont(QFont("Times", 40, QFont::Bold));
  72.  
  73. QPushButton *Button_7 = new QPushButton(tr("7"), this);
  74. Button_7->setGeometry((xscreenres/2) - 190, (yscreenres/2) + 135, 120, 120);
  75. Button_7->setFont(QFont("Times", 40, QFont::Bold));
  76.  
  77. QPushButton *Button_8 = new QPushButton(tr("8"), this);
  78. Button_8->setGeometry((xscreenres/2) - 60, (yscreenres/2) + 135, 120, 120);
  79. Button_8->setFont(QFont("Times", 40, QFont::Bold));
  80.  
  81. QPushButton *Button_9 = new QPushButton(tr("9"), this);
  82. Button_9->setGeometry((xscreenres/2) + 70, (yscreenres/2) + 135, 120, 120);
  83. Button_9->setFont(QFont("Times", 40, QFont::Bold));
  84.  
  85. QPushButton *Button_10 = new QPushButton(tr("Clear"), this);
  86. Button_10->setGeometry((xscreenres/2) - 190, (yscreenres/2) + 265, 120, 120);
  87. Button_10->setFont(QFont("Times", 30, QFont::Bold));
  88.  
  89. QPushButton *Button_11 = new QPushButton(tr("0"), this);
  90. Button_11->setGeometry((xscreenres/2) - 60, (yscreenres/2) + 265, 120, 120);
  91. Button_11->setFont(QFont("Times", 40, QFont::Bold));
  92.  
  93. QPushButton *Button_12 = new QPushButton(tr("Enter"), this);
  94. Button_12->setGeometry((xscreenres/2) + 70, (yscreenres/2) + 265, 120, 120);
  95. Button_12->setFont(QFont("Times", 30, QFont::Bold));
  96.  
  97. //connect(Button_1, SIGNAL(clicked()), qApp, SLOT(quit()));
  98. }
  99.  
  100. #endif /*KEYPAD_H_*/
To copy to clipboard, switch view to plain text mode