我正在学习CPP,本周末我学到更多关于QT的知识,我正在使用CLion和Cmakelist。我尝试编译一个项目但是当我添加宏Q_OBJECT时,它会说我:
对'vtable for DigitalClock'的未定义引用 我正在寻找解决我的问题并添加AUTOMOC但它仍然无法正常工作。
我的CMakelist是否正确?
cmake_minimum_required(VERSION 3.7.2)
project(cpp_rush3)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lncurses")
set(CMAKE_AUTOMOC_ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(Qt/widgets)
set(SOURCE_FILES
ncurses/Curse.cpp
ncurses/Curse.hpp
ncurses/Panel.cpp
ncurses/Panel.hpp
Qt/window.cpp
Qt/window.hpp
main.cpp)
set(QT_SOURCE_FILES
Qt/main.cpp
Qt/widgets/cpu.cpp
Qt/widgets/cpu.hpp
Qt/widgets/monitor.cpp
Qt/widgets/monitor.hpp
Qt/widgets/date.cpp
Qt/widgets/date.hpp
Qt/window.cpp
Qt/window.hpp)
add_executable(cpp_rush3 ${SOURCE_FILES})
add_executable(qt_cpp_rush3 ${QT_SOURCE_FILES})
target_link_libraries(cpp_rush3 Qt5::Widgets)
target_link_libraries(qt_cpp_rush3 Qt5::Widgets)