Qt学习笔记一

Qt忘记引用头文件报错

• 使用QMouseEvent类报错error: invalid use of incomplete type 'struct QMouseEvent'

..\ChineseChess\chessmanUI.cpp: In member function 'virtual void ChessmanUI::mousePressEvent(QMouseEvent*)':

..\ChineseChess\chessmanUI.cpp:26: error: invalid use of incomplete type 'struct QMouseEvent'

..\..\..\Qt\4.7.3\include\QtGui/../../src/gui/kernel/qwidget.h:76: error: forward declaration of 'struct QMouseEvent'

..\ChineseChess\chessmanUI.cpp:27: error: invalid use of incomplete type 'struct QMouseEvent'

..\..\..\Qt\4.7.3\include\QtGui/../../src/gui/kernel/qwidget.h:76: error: forward declaration of 'struct QMouseEvent'

..\ChineseChess\chessmanUI.cpp: In member function 'virtual void ChessmanUI::mouseMoveEvent(QMouseEvent*)':

..\ChineseChess\chessmanUI.cpp:46: error: invalid use of incomplete type 'struct QMouseEvent'

..\..\..\Qt\4.7.3\include\QtGui/../../src/gui/kernel/qwidget.h:76: error: forward declaration of 'struct QMouseEvent'

..\ChineseChess\chessmanUI.cpp:47: error: invalid use of incomplete type 'struct QMouseEvent'

..\..\..\Qt\4.7.3\include\QtGui/../../src/gui/kernel/qwidget.h:76: error: forward declaration of 'struct QMouseEvent'

原因是没有引用对应头文件:

#include 所以要在头文件添加引用头文件

你可能感兴趣的:(Qt学习笔记一)