我对 CMake 和简单的 QT 示例有疑问。我正在更新我的 CMake 配置以遵循现代的执行方式,这意味着支持 CMake > v3.0。
这是我的 CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project("test")
set(CMAKE_AUTOMOC ON)
find_package(Qt5 COMPONENTS Core REQUIRED)
message(STATUS "Qt5 version: ${Qt5_VERSION}")
get_target_property(QtCore_location Qt5::Core LOCATION)
message(STATUS "Qt5 version: ${QtCore_location}")
add_executable(Test main.cpp)
target_link_libraries(Test Qt5::QtCore)
Run Code Online (Sandbox Code Playgroud)
我的代码示例(main.cpp)
#include <QApplication>
#include <QProgressBar>
#include <QSlider>
int main(int argc, char **argv)
{
QApplication app (argc, argv);
// Create a container window
QWidget window;
window.setFixedSize(200, 80);
// Create a progress bar
// with the range between 0 and 100, and a starting value …
Run Code Online (Sandbox Code Playgroud)