Use O_QBJECT macro and to correct the errors you get you can either:
1) Declare your QWidget/QObject derived class in it's own .h file and define it in it's own .cpp file.
2) include the .moc file generated by moc after your class definition in the .cpp you have (add something like #include "xxxx.moc")
LE: also you want to use layouts instead of use the setGeometry to place your widgets into a window, read more here