1. 本例程只使用了基础类
2. 本例程qt非官方安装路径
cmake_minimum_required(VERSION 2.8)project(TestQT)
set (OLD_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
set (CMAKE_PREFIX_PATH "/opt/qt4x11")
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
set (CMAKE_PREFIX_PATH ${OLD_CMAKE_PREFIX_PATH})
include(${QT_USE_FILE})
set(pro_SOURCES test.cpp )
#SET(pro_HEADERS mainwindow.h )
#SET(pro_FORMS mainwindow.ui )
#QT4_WRAP_CPP(pro_HEADERS_MOC ${pro_HEADERS})
#QT4_WRAP_UI(pro_FORMS_HEADERS ${pro_FORMS}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(${QT_DEFINITIONS})
add_executable(TestQT ${pro_SOURCES})
target_link_libraries(TestQT ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})