PDA

View Full Version : Plotter



chrisdsimpson
7th April 2008, 19:38
Hi

I am trying to get the plotter example from the book C++ GUI programming with QT 4 to
work in my application. I am getting link errors and am not sure what is really causing it
I am using Visual Studio C++ V8 QT V4.3 I have included the plotter.cpp and plotter.h files in my project and am just calling "Plotter plotter;" with no code to actualy use it yet, but I can't get past the link errors does anybody have any ideas? The exact error is.

1>plotter.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Plotter::metaObject(void)const " (?metaObject@Plotter@@UBEPBUQMetaObject@@XZ)
1>plotter.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall Plotter::qt_metacast(char const *)" (?qt_metacast@Plotter@@UAEPAXPBD@Z)
1>plotter.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall Plotter::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Plotter@@UAEHW4Call@QMetaObject@@HPA PAX@Z)
1>C:\Documents and Settings\Chris Simpson\My Documents\Visual Studio 2005\Visual Studio Projects\WindowsINE\INE-DE\Debug\ine.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Chris Simpson\My Documents\Visual Studio 2005\Visual Studio Projects\WindowsINE\INE-DE\Debug\BuildLog.htm"
1>INE-DT - 4 error(s), 2 warning(s)

wysota
7th April 2008, 19:54
Looks like you forgot to rerun qmake after adding a Q_OBJECT macro to your class. Or forgot to call moc on the header and include moc_classname.cpp in the compilation in case you are not using qmake at all.

chrisdsimpson
7th April 2008, 20:13
This is an application I have taken over coding I am new to QT. I have not used the moc_myclass.cpp. I guess I don't understand the interaction with it. There are about 10 files build with designer creating myclass.ui that have the assocated moc_myclass.cpp files.

Thanks, Chris

wysota
7th April 2008, 23:30
So you need to add the 11th to the build process... or use qmake and forget about all the problems.

chrisdsimpson
8th April 2008, 21:32
OK I used the moc_plotter.cpp and got it to work corectly

Thanks for the help

Chris