How to configure CLion IDE for Qt Framework?

后端 未结 7 1481
忘掉有多难
忘掉有多难 2020-12-12 12:05

How to configure CLion IDE for Qt Framework? Is this IDE compatible with Qt, or are there other IDEs compatible with Qt?

I just want to try to use something else tha

7条回答
  •  被撕碎了的回忆
    2020-12-12 12:10

    You can build QT applications in CLion. QT Provides CMake modules that take care of all details.

    The following CMake script builds the example application 'Dynamic Layouts Example'

    cmake_minimum_required(VERSION 3.7)
    project(qtlayoutexample)
    set(CMAKE_CXX_STANDARD 14)
    
    # Find QT packages
    find_package(Qt5Widgets)
    
    # Add the include directories for the Qt 5 Widgets module to
    # the compile lines.
    include_directories(${Qt5Widgets_INCLUDE_DIRS})
    
    # Find includes in corresponding build directories
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    # Instruct CMake to run moc automatically when needed.
    set(CMAKE_AUTOMOC ON)
    
    # Add compiler flags for building executables (-fPIE)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
    
    qt5_generate_moc(main.cpp main.moc)
    
    # Tell CMake to create the qtlayoutexample executable
    add_executable(qtlayoutexample main.cpp dialog.cpp main.moc)
    
    #Link the qtlayoutexample executable to the Qt 5 widgets library.
    target_link_libraries(qtlayoutexample Qt5::Widgets)
    

    More information regarding building Qt applications with CMake.

提交回复
热议问题