Im havin some problem with Qt in Visual Studio 2010.
I have downloaded the qt binaries from this site, version Qt-4.7.3-dev-msvc2010-rdh.
This code copiles without any problem.
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget* parent);
protected:
void paintEvent(QPaintEvent *e);
private:
};
When I add this line:
void keyPressEvent(QKeyEvent *e);
This error happens
1>------ Build started: Project: lol, Configuration: Release Win32 ------
1>Build started 25/09/2012 21:04:40.
1>InitializeBuildStatus:
1> Creating "Release\lol.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>CustomBuild:
1> Moc'ing lol.h...
1>ClCompile:
1> All outputs are up-to-date.
1> moc_lol.cpp
1> lol.cpp
1> main.cpp
1> Generating Code...
1>lol.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall lol::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@lol@@MAEXPAVQMouseEvent@@@Z)
1>C:\Users\VTM\Documents\Visual Studio 2010\Projects\TC\Win32\Release\\lol.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.68
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It seems that the linker is not able to find keyPressEvent implementation.
Have you implemented keyPressEvent() in your Widget class? You will have to do that since your are declaring that in your class definition. Add the following code just to forward the event to baseclass.