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:
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_emit(int,struct QUObject *)" (?qt_emit@myMainForm@@UAE_NHPAUQUObject@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_invoke(int,struct QUObject *)" (?qt_invoke@myMainForm@@UAE_NHPAUQUObject@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_property(int,int,class QVariant *)" (?qt_property@myMainForm@@UAE_NHHPAVQVariant@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual char const * __thiscall myMainForm::className(void)const " (?className@myMainForm@@UBEPBDXZ)
Editor error LNK2001: unresolved external symbol "public: virtual void * __thiscall myMainForm::qt_cast(char const *)" (?qt_cast@myMainForm@@UAEPAXPBD@Z)
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)
Editor fatal error LNK1120: 6 unresolved externals
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_emit(int,struct QUObject *)" (?qt_emit@myMainForm@@UAE_NHPAUQUObject@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_invoke(int,struct QUObject *)" (?qt_invoke@myMainForm@@UAE_NHPAUQUObject@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual bool __thiscall myMainForm::qt_property(int,int,class QVariant *)" (?qt_property@myMainForm@@UAE_NHHPAVQVariant@@@Z)
Editor error LNK2001: unresolved external symbol "public: virtual char const * __thiscall myMainForm::className(void)const " (?className@myMainForm@@UBEPBDXZ)
Editor error LNK2001: unresolved external symbol "public: virtual void * __thiscall myMainForm::qt_cast(char const *)" (?qt_cast@myMainForm@@UAEPAXPBD@Z)
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)
Editor fatal error LNK1120: 6 unresolved externals
To copy to clipboard, switch view to plain text mode
//mymainform.h
#include "mainform.h"
#include "mywidget.h"
class myMainForm : public MainForm
{
Q_OBJECT
public:
myMainForm
( QWidget* parent
= 0,
const char* name
= 0, WFlags fl
= WType_TopLevel
);
~myMainForm();
MyWidget top;
};
//mymainform.h
#include "mainform.h"
#include "mywidget.h"
class myMainForm : public MainForm
{
Q_OBJECT
public:
myMainForm( QWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );
~myMainForm();
MyWidget top;
};
To copy to clipboard, switch view to plain text mode
//mymainform.cpp
#include "mymainform.h"
myMainForm
::myMainForm( QWidget* parent,
const char* name, WFlags fl
) : MainForm( parent, name, fl )
{
}
myMainForm::~myMainForm()
{
}
//mymainform.cpp
#include "mymainform.h"
myMainForm::myMainForm( QWidget* parent, const char* name, WFlags fl )
: MainForm( parent, name, fl )
{
}
myMainForm::~myMainForm()
{
}
To copy to clipboard, switch view to plain text mode
//main.cpp
#include "mymainform.h"
..........
//MainForm w;
myMainForm w;
w.resize(600,500);
a.setMainWidget(&w);
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
//main.cpp
#include "mymainform.h"
..........
//MainForm w;
myMainForm w;
w.resize(600,500);
a.setMainWidget(&w);
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
To copy to clipboard, switch view to plain text mode
What happen?
Bookmarks