![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
原休
这个作者很懒,什么都没留下…
展开
-
在QT界面中使用ico/png等图片文件,生成exe后不依赖外部文件
为了更加形象地展示UI中某些控件的作用,通常会给图片添加ico/png等图片文件,但如果直接从文件中加载,那么生成的exe也会依赖加载的文件路径,如果路径下没有图片,exe上的对应的控件便不会显示。一种可行的解决方法是,将图片直接放入代码中,因为图片的本质是二进制字节码,可以将图片作为二进制码解析出来,然后放入代码中作为一个大数组,大数组便会被编译到exe中,不会依赖外部的图片文件。自己再写一个图片文件的读取解析工具比较麻烦,而且容易出错。幸运的是,QT已经有这种解决方法的实际实现了,这种方法就是qrc文原创 2022-05-09 10:47:31 · 1613 阅读 · 1 评论 -
用于生成线性表文件的代码
std::ofstream fout("linear_0_to_512.txt");std::vector<int> data(512);std::iota(data.begin(), data.end(), 0);std::copy(data.begin(), data.end(), std::ostream_iterator<double>(fout, "\n"));fout.close();原创 2022-03-23 16:34:43 · 330 阅读 · 0 评论 -
使用CLR对C++ dll进行封装
CLR生成NET.FrameWorks框架下的dll原创 2022-02-19 16:00:06 · 4463 阅读 · 1 评论 -
成员函数里的静态变量
class Test{public: void func() { static int count = 0; printf("%d\n", count++); }};Test a, b;a.func();//0b.func();//1原创 2021-09-29 17:33:55 · 182 阅读 · 0 评论 -
C++中move语义与forward语义的实现与区别
/** * @brief Forward an lvalue. * @return The parameter cast to the specified type. * * This function is used to implement "perfect forwarding". */ template<typename _Tp> constexpr _Tp&& forward(typename std::r...原创 2021-08-14 22:56:14 · 184 阅读 · 0 评论 -
Keil编译STM32时不使用MicroLib并取消semihost模式
不使用MicroLib,在keil的Debug选项中取消选择即可,取消选择MicroLib后,再Debug运行时会进入semihost模式,要点多次F5后程序才进入main函数,在烧写完成后,重新上电启动STM32时,程序运行不了。这时需要添加一个C文件,对其中一些函数进行重定向。重定向代码如下#include "stdio.h"#pragma import(__use_no_semihosting_swi) //取消semihost模式#pragma import(__use_no_semihos原创 2021-05-18 21:01:58 · 1921 阅读 · 0 评论 -
C++中内存对齐导致memcpy出错
typedef unsigned char uint8_t;typedef unsigned short uint16_t;typedef unsigned int uint32_t;typedef struct{ uint8_t Analog_Out_En; //模拟输出使能信号 uint8_t Analog_Out_Source; //模拟输出信号源 uint8_t Analog_Out_Mode; //模拟输出模式:0-电压,1-电流 int原创 2021-01-25 23:03:57 · 1048 阅读 · 0 评论 -
往二进制文件中写入char值0x0A出现问题
std::ofstream fout; std::string filename = "data.dat"; fout.open(filename, std::ios::out); char ch = 10; fout.write(&ch, 1); fout.close();往data.dat里写入0x0A的时候前面多了一个0x0D,这是因为,fout.open后面没有加std::ios::binary,所以写的是文本文件,0x0A是换行键,所以写的时候前面多了一个0x0D多了个回车.原创 2021-01-25 22:54:53 · 674 阅读 · 0 评论 -
c语言内存对齐的一些操作
#include <iostream>struct TestStruct1 //对齐到4字节{ char c1; short s; char c2; int i;};struct TestStruct2{ char c1; char c2; short s; int i;};struct TestStruct4{ char a; long b;};struct TestStruct5{ char c; TestStruct4 d; long原创 2020-12-06 13:40:43 · 97 阅读 · 0 评论 -
通过查询注册表读取当前可用串口
/** @brief:宽字符串转换为string*/std::string wideCharToString(wchar_t* pWCStrKey){ int pSize = WideCharToMultiByte(CP_OEMCP, 0, pWCStrKey, wcslen(pWCStrKey), NULL, 0, NULL, NULL); char* pCStrKey = new char[pSize + 1]; WideCharToMultiByte(CP_OEMCP, 0, pWCS.原创 2020-09-24 18:01:17 · 288 阅读 · 0 评论 -
常用连接
VSCode上写C++https://blog.csdn.net/qq_34347375/article/details/80851417原创 2019-09-19 14:31:08 · 85 阅读 · 0 评论 -
libtorch实现yolo
cv::Mat origin_image, resized_image;int input_image_size = 416;origin_image = cv::imread("004.bmp");resized_image = origin_image.clone();cv::resize(resized_image, resized_image, cv::Size(input_ima...原创 2019-09-16 21:08:53 · 1024 阅读 · 0 评论 -
OpenCV项目属性
通用属性⇒\Rightarrow⇒ VC++目录 ⇒\Rightarrow⇒包含目录中添加D:\Professional\OpenCV\opencv\build\includeD:\Professional\OpenCV\opencvbuild\include\opencvD:\Professional\OpenCV\opencv\build\include\opencv2第二步:通用属性...原创 2019-02-26 17:07:48 · 155 阅读 · 0 评论 -
C++学习
链接网站C++实例代码 https://blog.csdn.net/CV2017/article/details/82597666原创 2019-02-11 17:26:09 · 301 阅读 · 0 评论