Hi,
I'm subclassing MainForm class (create from qtDesigner). I code insert new mymainform.cpp e mymainform.h. and seems ok. But when I create an instance of it in main.cpp, linker get these errors:
Qt Code:
  1. Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_emit(int,struct QUObject *)" (?qt_emit@myMainForm@@UAE_NHPAUQUObject@@@Z)
  2. Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_invoke(int,struct QUObject *)" (?qt_invoke@myMainForm@@UAE_NHPAUQUObject@@@Z)
  3. Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_property(int,int,class QVariant *)" (?qt_property@myMainForm@@UAE_NHHPAVQVariant@@@Z)
  4. Editor error LNK2001: unresolved external symbol "public: virtual char const * __thiscall myMainForm::className(void)const " (?className@myMainForm@@UBEPBDXZ)
  5. Editor error LNK2001: unresolved external symbol "public: virtual void * __thiscall myMainForm::qt_cast(char const *)" (?qt_cast@myMainForm@@UAEPAXPBD@Z)
  6. Editor error LNK2019: unresolved external symbol "public: static class QMetaObject * __cdecl myMainForm::staticMetaObject(void)" (?staticMetaObject@myMainForm@@SAPAVQMetaObject@@XZ) referenced in function "public: virtual class QMetaObject * __thiscall myMainForm::metaObject(void)const " (?metaObject@myMainForm@@UBEPAVQMetaObject@@XZ)
  7. Editor fatal error LNK1120: 6 unresolved externals
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //mymainform.h
  2. #include "mainform.h"
  3. #include "mywidget.h"
  4. class myMainForm : public MainForm
  5. {
  6. Q_OBJECT
  7.  
  8. public:
  9. myMainForm( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );
  10. ~myMainForm();
  11. MyWidget top;
  12. };
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //mymainform.cpp
  2. #include "mymainform.h"
  3. myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
  4. : MainForm( parent, name, fl )
  5. {
  6. }
  7.  
  8. myMainForm::~myMainForm()
  9. {
  10. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //main.cpp
  2. #include "mymainform.h"
  3. ..........
  4. //MainForm w;
  5. myMainForm w;
  6. w.resize(600,500);
  7. a.setMainWidget(&w);
  8. w.show();
  9. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
  10. return a.exec();
To copy to clipboard, switch view to plain text mode 
What happen?