C++ 替换字符串
摘要:// 替换字符串的某一字符 std::string& replace_all(std::string& str, const std::string& old_value, const std::string& new_value) { while (true) { std::string::siz
阅读全文
posted @
2021-08-26 15:45
缘随风烬
阅读(1258)
推荐(0)
C++ 清除字符串所有空格
摘要:// 清空字符串所有空格 std::string& ClearAllSpace(std::string &str) { int index = 0; if (!str.empty()) { while ((index = str.find(' ', index)) != std::string::n
阅读全文
posted @
2021-08-26 15:42
缘随风烬
阅读(1408)
推荐(0)
C++ 字符串切割
摘要:std::vector<std::string> split(std::string str, std::string pattern) { std::string::size_type pos; std::vector<std::string> result; str += pattern;//扩
阅读全文
posted @
2021-08-26 15:40
缘随风烬
阅读(174)
推荐(0)
C++ UDP接收和发送
摘要:class UDP { public: UDP() { RecvAddrSize = sizeof(RecvAddr); int nResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (nResult != NO_ERROR) { std::cout
阅读全文
posted @
2021-08-26 15:39
缘随风烬
阅读(3138)
推荐(0)
QT 线程池
摘要:1、建立一个新的类,且需要继承QObject和QRunnable Class MyThreadPool : public QObject, public QRunnable{ }; 注意在继承的时候,一定是QObject在前,QRunnable在后,不然会报错。 2、声明各个函数。 class My
阅读全文
posted @
2021-08-26 14:53
缘随风烬
阅读(373)
推荐(0)
C++ socket的bind()函数遇到的问题
摘要:问题: 严重性 代码 说明 项目 文件 行 禁止显示状态错误 C2440 “=”: 无法从“std::_Binder<std::_Unforced,SOCKET &,sockaddr *,unsigned int>”转换为“int” 原因: 在C++11中新增std::bind(_Fp &&__f,
阅读全文
posted @
2021-08-20 00:18
缘随风烬
阅读(517)
推荐(0)
QML -- 》控件的添加与删除
摘要:import QtQuick 2.0 Rectangle { width: 480 height: 300 color: "white" ListModel { id: theModel ListElement { number: 0 } ListElement { number: 1 } List
阅读全文
posted @
2021-08-12 15:03
缘随风烬
阅读(506)
推荐(0)
QML --》 GridView(网格视图)
摘要:import QtQuick 2.0 Rectangle{ width: 240; height: 300; color: "white" GridView{ anchors.fill: parent anchors.margins: 20 clip: true // 设置clip属性为true,来
阅读全文
posted @
2021-08-12 14:35
缘随风烬
阅读(904)
推荐(0)
QML -- > ListView(列表视图)
摘要:1、对于用户,ListView是一个滚动区域,支持惯性滚动。(代理项delegates) import QtQuick 2.0 Rectangle{ width: 80 height: 300 color: "white" ListView{ anchors.fill: parent anchors
阅读全文
posted @
2021-08-12 09:47
缘随风烬
阅读(3258)
推荐(0)
QML --> ListModel(链表模型)的简单使用
摘要:一个链表模型(ListModel)是由许多个链表元素(ListElement)组成。 import QtQuick 2.0 Column{ spacing: 2 Repeater{ model:ListModel{ ListElement{name:"单机"; surfaceColor:"gray"
阅读全文
posted @
2021-08-11 16:57
缘随风烬
阅读(1695)
推荐(0)
QML -->状态与过渡(简单的交通灯)
摘要:import QtQuick 2.0 Item{ id:root; state: "go" // 设置初始状态 states: [ State { // 设置每个目标的颜色,并命名 name: "go" PropertyChanges {target: light1; color:"green"}
阅读全文
posted @
2021-08-06 17:16
缘随风烬
阅读(277)
推荐(0)
QML -- 》 动画分组(二)
摘要:Item{ id:root; width: 480; height: 300; property int duration: 3000; // 设置时间3000ms Rectangle{ // 设置天空颜色 id:sky; width: parent.width; height: 200; grad
阅读全文
posted @
2021-08-06 15:34
缘随风烬
阅读(74)
推荐(0)
QML --》动画分组
摘要:1、平行动画 关键字(ParallelAnimation):当开始时,平行元素的所有子动画都会平行运行,它允许你在同一时间使用不同的属性来播放动画。 import QtQuick 2.0 Rectangle{ id:root width: 1000; height: 1000; property i
阅读全文
posted @
2021-08-06 10:26
缘随风烬
阅读(99)
推荐(0)
QML --》 动画元素
摘要:1、PropertyAnimation(属性动画) - 使用属性值改变播放动画。 2、NumberAnimation(数字动画) - 使用数字改变播放的动画。 3、ColorAnimation(颜色动画) - 使用颜色改变播放的动画。 4、RotationAnimation(旋转动画) - 使用旋转
阅读全文
posted @
2021-08-05 16:37
缘随风烬
阅读(286)
推荐(0)
QML -->按键元素
摘要:1、属性key允许你通过按键来执行你的代码,如up, down, left, right。 import QtQuick 2.0 Rectangle{ width: 400; height: 200; GreenRect{ // 封装的绿色方框组件 id:square; x:8;y:8; } foc
阅读全文
posted @
2021-08-05 14:37
缘随风烬
阅读(146)
推荐(0)
QML --》 文本输入TextInput与TextEdit
摘要:1、文本输入 文本输入允许用户输入一行文字。 import QtQuick 2.0 Rectangle{ width: 200; height: 80; color: "linen"; TextInput{ id:input1 x:8;y:8; width: 96; height: 20; focu
阅读全文
posted @
2021-08-05 11:45
缘随风烬
阅读(949)
推荐(0)
QML --> 定位器与Repeater(重复元素)
摘要:1、定位器Row Row的就是行的意思,就是按从左到右方向排列。 2、定位器Column Column(列)将它的子对象通过顶部对齐的方式进行排列。 3、定位器Grid Grid(栅格)通过设置行数和列数将对象排列在一个栅格中,行数或列数可只设置一个,栅格元素会自动的计算子项目总数来获取配置。 4、
阅读全文
posted @
2021-08-04 15:51
缘随风烬
阅读(1463)
推荐(0)
QML --> 简单平移、旋转和缩放
摘要:一、改变物体的几何状态,实现对象的平移、旋转和缩放。 1、平移: 简单的平移是通过改变x,y坐标来实现的。 2、旋转: 旋转是通过改变rotation属性来实现的,这个值是使用角度来作为单位的(0,360) 3、缩放: 缩放是通过关键字scale属性来实现的,小于1表示缩小,大于1表示放大。 4、I
阅读全文
posted @
2021-08-04 15:01
缘随风烬
阅读(2054)
推荐(0)
QML --》矩形框
摘要:1、关键字 Rectangle{} color:颜色 border.color:边框颜色 border.width:边框宽度 radius:圆角 2、添加渐变色: gradient: Gradient{ GradientStop{position: 0.0; color: "black"} Grad
阅读全文
posted @
2021-08-03 16:11
缘随风烬
阅读(728)
推荐(0)
QML -->变量和函数
摘要:1、在qml中定义变量的方法: property int spacePresses: 0 其中property为关键字, int为类型, spacePresses为变量名, 0表示值 2、定义函数的方法 function increment(){ spacePresses = spacePresse
阅读全文
posted @
2021-08-03 15:58
缘随风烬
阅读(2653)
推荐(0)
QML---》初写qml代码
摘要:1、初识QML QML是与HTML类似的一种标记语言。在QtQuick中将由标签组成的元素封装在大括号中 Item{} 。这样的设计重新定义了界面的创建方式,对于开发者而言更加简单易读。可以使用JavaScript开发界面功能,也可以使用本地Qt C++函数接口扩展界面功能。简单来说,声明式的UI被
阅读全文
posted @
2021-08-03 15:22
缘随风烬
阅读(415)
推荐(0)