Chinaunix首页 | 论坛 | 博客
  • 博客访问: 967791
  • 博文数量: 109
  • 博客积分: 554
  • 博客等级: 中士
  • 技术积分: 2577
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-04 12:49
文章分类

全部博文(109)

文章存档

2019年(5)

2016年(7)

2015年(9)

2014年(1)

2013年(71)

2012年(16)

分类: 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:

屏幕快照 2016 06 09 16 20 46

uic:

屏幕快照 2016 06 09 16 17 41

6. Clion 2016 PyQt配置

屏幕快照 2016 06 09 16 36 26

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_()

运行结果:

屏幕快照 2016 06 09 16 40 10

 利用pyuic 把ui文件生成py文件

配置:

屏幕快照 2016 06 09 17 32 42

代码中利用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文件

屏幕快照 2016 06 09 16 57 34

保存ui文件到项目目录

右键ui文件,菜单中选择external tool->uic

屏幕快照 2016 06 09 16 58 12

此时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();
}

运行结果:

屏幕快照 2016 06 09 17 00 25

 

阅读(5712) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~