久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何為 Qt 框架配置 CLion IDE?

How to configure CLion IDE for Qt Framework?(如何為 Qt 框架配置 CLion IDE?)
本文介紹了如何為 Qt 框架配置 CLion IDE?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

如何為 Qt 框架配置 CLion IDE?這個IDE是否兼容Qt,或者還有其他兼容Qt的IDE嗎?

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

我只是想嘗試使用 Qt Creator 以外的東西.

I just want to try to use something else than Qt Creator.

推薦答案

我和你一樣絕望,直到我讀到 這個 Quora 討論.它非常適合我!

I was as desperate as you, until I read this Quora discussion. It worked perfectly for me!

總而言之,有兩個主要步驟:

To summarize, there are 2 main steps:

首先,CLion 使用 CMake 來編譯您的代碼.它基于 CMake 配置文件(例如CMakeLists.txt").您必須添加基于 Qt 的 CMake 命令(帶有find_package"和target_link_libraries"的行):

Firstly, CLion uses CMake to compile your code. It is based on CMake configuration files (e.g "CMakeLists.txt"). You have to add Qt based CMake commands (the lines with 'find_package' and 'target_link_libraries'):

cmake_minimum_required(VERSION 3.5)
project(myqtproject)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
find_package(Qt5Widgets REQUIRED)                 <-- this line

add_executable(myqtproject ${SOURCE_FILES})

target_link_libraries(myqtproject Qt5::Widgets)   <-- this line

其次,CLion 必須使用 Qt 安裝的 cmake 二進(jìn)制文件.為此,請訪問:'Preferences' -> 'Build, Execution, Deployment' -> 'CMake' 并在 'CMake options' 中添加 Qt 使用的 CMake 路徑,該路徑應(yīng)該在安裝 Qt 的目錄中.例如,在 OSX 上:

Secondly, CLion has to use the cmake binary installed by Qt. For that, go to: 'Preferences' -> 'Build, Execution, Deployment' -> 'CMake' and in 'CMake options' append the CMake path that Qt uses, which should be in the directory where Qt is installed. For instance, on OSX:

-DCMAKE_PREFIX_PATH=/Users/edouard/Qt/5.7/clang_64/lib/cmake

您可以通過在 main.cpp 中編寫一個小測試腳本來測試一切是否正常:

You can test that everything is working fine, by doing a little test script in main.cpp:

#include <QApplication>
#include <QDebug>

using namespace std;

int main() {
    qDebug() << QT_VERSION_STR;
    return 1;
}

應(yīng)該顯示如下內(nèi)容:

/Users/edouard/Library/Caches/CLion2016.2/cmake/generated/myqtproject-89a4132/89a4132/Debug/untitled
5.7.0

Process finished with exit code 1

更新

我遇到了添加 Qt5 模塊(例如 QSql)的問題.您可以通過添加 CMakeLists.txt 來做到這一點:

I was stuck with the problem of adding Qt5 modules (for instance QSql). You can do this by adding in the CMakeLists.txt:

find_package(Qt5Sql REQUIRED)

就在另一個find_package之后,并在最后一行添加:

just after the other find_package, and adding in the last line:

target_link_libraries(myqtproject Qt5::Widgets Qt5::Sql)

您可以使用所有其他 Qt5 模塊執(zhí)行此操作.

You can do this with all the other Qt5 modules.

這篇關(guān)于如何為 Qt 框架配置 CLion IDE?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 四虎在线观看 | 欧美精品久久久 | 久久综合狠狠综合久久综合88 | 免费成人高清在线视频 | 日本中文在线视频 | 一区二区三区视频在线 | 亚洲一区在线免费观看 | 欧美一级视频在线观看 | 亚洲一区 | 九九热这里只有精品6 | 亚洲欧洲精品一区 | 精品国产第一区二区三区 | 日韩免费一区二区 | 免费天天干 | 国产精品伦一区二区三级视频 | 国产亚洲精品美女久久久久久久久久 | 亚洲欧美国产一区二区三区 | 日本精品一区二区三区在线观看 | 亚州精品天堂中文字幕 | 亚洲欧美日本国产 | 久久久福利 | 一区二区精品 | 色资源在线视频 | 91中文字幕在线 | 亚洲精品2区 | 五月激情综合网 | 久久精品国产亚洲夜色av网站 | 香蕉久久久 | 偷拍自拍第一页 | 国产色网 | 免费同性女女aaa免费网站 | 欧美xxxⅹ性欧美大片 | 夜夜操av | 亚洲狠狠爱一区二区三区 | 精品久久久久一区二区国产 | 精品一区二区久久久久久久网精 | 国产伦一区二区三区 | 久草网址 | av免费网站在线观看 | 中文字幕国产 | 日韩欧美在线观看视频网站 |