QT学习之路--创建一个对话框

  Q_OBJECT:这是一个宏,凡是定义信号槽的类都必须声明这个宏.

  函数tr()全名是QObject::tr(),被他处理过的字符串可以使用工具提取出来翻译成其他语言,也就是做国际化使用。

对于QT学习之路:Qt学习之路(7):创建一个对话框(上)这个程序。编译出现

 invalid use of incomplete type ‘class QPushButton’
  findButton->setEnabled(!text.isEmpty());
            ^
In file included from /usr/include/qt5/QtWidgets/QDialog:1:0,
                 from finddialog.h:4,
                 from finddialog.cpp:3:
/usr/include/qt5/QtWidgets/qdialog.h:52:7: error: forward declaration of ‘class QPushButton’
 class QPushButton;


解决办法:  

1.he error should come from your .pro file since your are using Qt5 you should include:

QT += widgets

Change all instances of

#include <QtGui>

to

#include <QtWidgets>

 函数 tr()全名是
QObject::tr(),被它处理的字符串可以使用工具提取出来翻译成其他语言,也就是做国际化使用。

字符串中的&代表快捷键。

 

posted on 2016-10-11 20:17  白宫飘红旗  阅读(188)  评论(0编辑  收藏  举报