Chinaunix首页 | 论坛 | 博客
  • 博客访问: 89264
  • 博文数量: 31
  • 博客积分: 15
  • 博客等级: 民兵
  • 技术积分: 142
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-08 13:05
文章分类

全部博文(31)

文章存档

2014年(17)

2013年(11)

2012年(3)

我的朋友

分类: C/C++

2014-03-04 22:17:52

C++ GUI Programming with Qt 4上一段代码,编译不能通过:

点击(此处)折叠或打开

  1. finddialog.cpp: In constructor 'FindDialog::FindDialog(QWidget*)':
  2. finddialog.cpp:5:38: error: invalid use of incomplete type 'class QLabel'
  3. In file included from finddialog.cpp:2:0:
  4. finddialog.h:7:7: error: forward declaration of 'class QLabel'
  5. finddialog.cpp:6:17: error: invalid use of incomplete type 'class QLineEdit'
  6. In file included from finddialog.cpp:2:0:
  7. finddialog.h:8:7: error: forward declaration of 'class QLineEdit'
  8. finddialog.cpp:7:7: error: invalid use of incomplete type 'class QLabel'
  9. In file included from finddialog.cpp:2:0:
  10. finddialog.h:7:7: error: forward declaration of 'class QLabel'
  11. finddialog.cpp:8:48: error: invalid use of incomplete type 'class QCheckBox'
  12. In file included from finddialog.cpp:2:0:
  13. finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
  14. finddialog.cpp:9:57: error: invalid use of incomplete type 'class QCheckBox'
  15. In file included from finddialog.cpp:2:0:
  16. finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
  17. finddialog.cpp:10:42: error: invalid use of incomplete type 'class QPushButton
在Qt官网wiki找到了答案:

点击(此处)折叠或打开

  1. #include <QtGui>
改为
点击(此处)折叠或打开
  1. #include <QtWidgets>
在pro文件中增加

点击(此处)折叠或打开

  1. QT += widgets


阅读(3434) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~