分类: C/C++
2016-06-09 16:29:46
1. 安装Clion 2016
2. 破解Clion 2016
将JetbrainsCrack.jar拷贝到Clion安装目录的bin目录下,修改此目录的clion.vmoptions文件,
结尾加上javaagent:../bin/JetbrainsCrack.jar
启动Clion,注册码填上一下内容
hisCrackLicenseId-{
"licenseId":"ThisCrackLicenseId",
"licenseeName":"idea",
"assigneeName":"",
"assigneeEmail":"idea@163.com",
"licenseRestriction":"For This Crack, Only Test! Please support genuine!!!",
"checkConcurrentUse":false,
"products":[
{"code":"II","paidUpTo":"2099-12-31"},
{"code":"DM","paidUpTo":"2099-12-31"},
{"code":"AC","paidUpTo":"2099-12-31"},
{"code":"RS0","paidUpTo":"2099-12-31"},
{"code":"WS","paidUpTo":"2099-12-31"},
{"code":"DPN","paidUpTo":"2099-12-31"},
{"code":"RC","paidUpTo":"2099-12-31"},
{"code":"PS","paidUpTo":"2099-12-31"},
{"code":"DC","paidUpTo":"2099-12-31"},
{"code":"RM","paidUpTo":"2099-12-31"},
{"code":"CL","paidUpTo":"2099-12-31"},
{"code":"PC","paidUpTo":"2099-12-31"}
],
"hash":"2911276/0",
"gracePeriodDays":7,
"autoProlongated":false}
3. 安装Qt5.5,和Qt Designer
brew install qt5
双击Qt designer的img文件安装
4. 安装PyQt5
brew install pyqt5
brew install python3
5. Clion外部工具配置Qt Designer和Uic
Qt Designer:
uic:
6. Clion 2016 PyQt配置
7 . 测试PyQt
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
if __name__ =="__main__":
app = QApplication(sys.argv)
w = QDialog()
w.resize(200, 300)
w.setWindowTitle("test PyQt5 ")
btn = QPushButton("ok")
hbox = QHBoxLayout()
hbox.addWidget(btn)
w.setLayout(hbox)
w.show()
app.exec_()
运行结果:
利用pyuic 把ui文件生成py文件
配置:
代码中利用pyuic生成的ui
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
from untitled import Ui_Form
if __name__=="__main__":
app = QApplication(sys.argv)
w = QWidget()
ui = Ui_Form()
ui.setupUi(w)
w.show()
sys.exit(app.exec_())
8. 测试QT c++开发
修改CMakeList.txt
cmake_minimum_required(VERSION 3.4)
project(test1)
set(QT_HOME "/usr/local/Cellar/qt5/5.5.1_2/")
set(CMAKE_PREFIX_PATH ${QT_HOME})
#INCLUDE_DIRECTORIES(${QT_HOME}/include/QtCore)
#INCLUDE_DIRECTORIES(${QT_HOME}/include/QtWidgets)
#INCLUDE_DIRECTORIES(${QT_HOME}/include/QUiTools)
set(CMAKE_INCLUDE_CURRENT_DIR on)
set(CMAKE_AUTOMOC )
set(CMAKE_AUTOUIC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#找到需要的qt库,配置好后clion可以自动补全代码
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5UiTools REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(test1 ${SOURCE_FILES})
#使应用程序链接qt相应的库
target_link_libraries(test1 Qt5::Widgets Qt5::UiTools)
Qt Designer建立ui文件
保存ui文件到项目目录
右键ui文件,菜单中选择external tool->uic
此时Clion调用uic把ui文件转化为c++头文件
编辑c++文件
#include#include #include #include #include #include #include #include
#include "ui_untitled.h"
int main(int argc, char *argv[])
{
QApplication *app = new QApplication(argc, argv);
QWidget *w = new QWidget;
Ui::Form ui;
ui.setupUi(w);
w->show();
return app->exec();
}
运行结果: