背景:读霍亚飞老师的《Qt Creator快速入门(第三版)》第三章3.3.3
版本:Qt Creator 4.15.0
Qt 5.15.2 (Clang 11.0 (Apple), 64 bit)
直接运行源码出现主要三个error:
- ‘QtGui/QApplication’ file not found
- Unknown type name ‘QIntValidator’
- no member named ‘setCodeForTr’ in ‘QTextCodec’
第三个error在我的前一篇博客中已解决。
那么如何解决第1、2个error?
- 在main.cpp中将
#include <QtGui/QApplication>
改成#include <QApplication>
- 通过查阅官方资料发现,如果使用QIntValidator则需要在mywidget.cpp中添加
#include <QIntValidator>
以上~