我在 Visual Studio 2010 中遇到了 Qt 的一些问题。我已经从这个站点下载了 qt 二进制文件,版本为 Qt-4.7.3-dev-msvc2010-rdh。这段代码编译没有任何问题。
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget* parent);
protected:
void paintEvent(QPaintEvent *e);
private:
};
当我添加这一行时:
void keyPressEvent(QKeyEvent *e);
发生此错误
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 ==========