美文网首页
Qt学习笔记一

Qt学习笔记一

作者: 子叶2019 | 来源:发表于2019-03-31 10:05 被阅读0次

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 <QMouseEvent>所以要在头文件添加引用头文件

相关文章

网友评论

      本文标题:Qt学习笔记一

      本文链接:https://www.haomeiwen.com/subject/nxdybqtx.html