我尝试将项目从Qt4转换为Qt5。直到现在stackoverflow搜索和谷歌帮助了我,但现在我被卡住了。
我已经重写了cmake文件,并且放置了所有包含到新Qt标头的包含。还应该正确添加库。在我的eclipse项目中找到了所有标题,但是对于某些对象,eclipse下划线为红色,并带有以下注释:
无法解析符号XXX
XXX
例如:
QMainWindow
QWidget
QGroupBox
QPushButton
,QLineEdit
等其他对象未加下划线。
老实说,从Qt4到Qt5的转换,我从Win / VS10切换到Linux / Eclipse。
所以任何人都可以给我一个提示?
真的很感激。 感谢
编辑:如何在cmake中添加Qt:
find_package(Qt5Widgets)
if (Qt5Widgets_FOUND)
message(STATUS "Qt5Widgets found.")
else (Qt5Widgets_FOUND)
message(STATUS "Qt5Widgets not found!")
endif (Qt5Widgets_FOUND)
find_package(Qt5OpenGL)
if (Qt5OpenGL_FOUND)
message(STATUS "QtOpenGl found.")
else (Qt5OpenGL_FOUND)
message(STATUS "QtOpenGL not found!")
endif (Qt5OpenGL_FOUND)
...
include_directories( ${Qt5Widgets_INCLUDES} ${Qt5OpenGL_INCLUDES})
add_executable(exp_test_qtTemplate ${files} )
target_link_libraries( exp_test_qtTemplate ${OPENGL_LIBRARIES} ${Boost_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5OpenGL_LIBRARIES})
这在qt生成的moc文件中很奇怪
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'GlViewer.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.0.1. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
看起来像是Qt的安装失败。