当前位置:网站首页>Qt char型转QString型 16进制与char型 转 16进制整型
Qt char型转QString型 16进制与char型 转 16进制整型
2022-07-24 05:21:00 【乔伊波伊 o(*^@^*)o】
Qt 字符转换
Qt char型转QString型 16进制与char型 转 16进制整型
去除字符Qstring 字符串当中不需要的字符
代码如下(示例):
void Widget::parseData(QString &str1)
{
char array[]={
'f',':'}; //需要去除的字符 f、:、
int length = sizeof (array)/sizeof (char);
for(int i=0;i<length;i++)
{
QString tmp = QString(array[i]);
if(str1.contains(tmp))
{
str1 =str1.replace(tmp,"");
}
}
}
char 转 Qstring 16进制
代码如下(示例):
QString Widget::Byte_16(uchar *Data,int iLength) //输入 uchar 型 字符串,返回 QString 型 16进制 字符串。
{
QString ST="",strT;
int iB,iS;
char cB,cS;
//---
for (int i=0;i<iLength;i++)
{
iB = *(Data+i)/16;
if (iB>=10)
{
cB = 'A' + (iB-10);
}
else
cB = '0' + iB;
iS = *(Data+i)%16;
if (iS >= 10)
{
cS = 'A' + (iS-10);
}
else
cS = '0' + iS;
strT=QString("%1%2 ").arg(cB).arg(cS);
ST += strT;
}
return ST;
}
QlineEdit 获取 QString字符串转16进制的整型
代码如下(示例):
QString g_str =g_edit_4->text();
bool ok;
int length = g_str.size()/3+1; //字符串除3后的字节长度,以每次获取三个
uchar array[length];
for(int i = 0; i<=length; i++)
{
array[i] = (uchar) g_str.mid(i*3,2).toUInt(&ok,16); //mid 每隔三个 获取两个
}
char *p = (char *)array; //使用指针指向整型,从而达到 用char 型 输出整型16进制
g_sender->writeDatagram(p,QHostAddress(g_ip),g_port);
边栏推荐
- GCC 中__attribute__((constructor)和__attribute__(((destructor))的注意事项。
- "Statistical learning methods (2nd Edition)" Li Hang Chapter 16 principal component analysis PCA mind map notes and after-school exercise answers (detailed steps) PCA matrix singular value Chapter 16
- 信号与系统:希尔伯特变换
- Subsystem technology and ecology may memorabilia | square one plan launched, Boca launched xcm!
- 多商户商城系统功能拆解06讲-平台端商家入驻协议
- 《统计学习方法(第2版)》李航 第15章 奇异值分解 SVD 思维导图笔记 及 课后习题答案(步骤详细)SVD 矩阵奇异值 十五章
- DeepSort 总结
- 测试数据增强后标签和数据集是否对应
- 数据归一化
- Positional argument after keyword argument
猜你喜欢

Typora 安装包2021年11月最后一次免费版本的安装包下载V13.6.1

删除分类网络预训练权重的的head部分的权重以及修改权重名称

Multi merchant mall system function disassembly lecture 05 - main business categories of platform merchants

Help transform traditional games into gamefi, and web3games promote a new direction of game development

多商户商城系统功能拆解04讲-平台端商家入驻

LSTM神经网络

Positional argument after keyword argument

labelme转voc代码中的一个小问题

Are you still trying to limit MySQL paging?

Chapter IV decision tree summary
随机推荐
Points for attention in adding spp module to the network
Numpy array broadcast rule memory method array broadcast broadcast principle broadcast mechanism
[MYCAT] MYCAT installation
《统计学习方法(第2版)》李航 第16章 主成分分析 PCA 思维导图笔记 及 课后习题答案(步骤详细)PCA 矩阵奇异值 第十六章
HAL_Delay()延时误差约1ms的问题
Zotero快速上手指南
Positional argument after keyword argument
《统计学习方法(第2版)》李航 第22章 无监督学习方法总结 思维导图笔记
systemctl + journalctl
《信号与系统》(吴京)部分课后习题答案与解析
第四章 决策树总结
Official account development custom menu and server configuration are enabled at the same time
Delete the weight of the head part of the classification network pre training weight and modify the weight name
Xshell远程访问工具
What do programmers often mean by API? What are the API types?
Recommend a fully open source, feature rich, beautiful interface mall system
多商户商城系统功能拆解04讲-平台端商家入驻
tensorflow和pytorch框架的安装以及cuda踩坑记录
Multi merchant mall system function disassembly Lecture 10 - platform end commodity units
《统计学习方法(第2版)》李航 第14章 聚类方法 思维导图笔记 及 课后习题答案(步骤详细) k-均值 层次聚类 第十四章