首页 > 其他分享 >Qt5.12实战之基本数据类型

Qt5.12实战之基本数据类型

时间:2023-03-20 12:32:00浏览次数:36  
标签:实战 Qt5.12 符号 int 数据类型 unsigned long signed type




Qt5.12实战之基本数据类型_c语言




Qt5.12实战之基本数据类型_#include_02


注: macosx下要加上 #include <QIODevice> //for macosx

endl替换为Qt::endl;



Qt5.12实战之基本数据类型_Powered by 金山文档_03


示例源码:

#include <QCoreApplication>
#include <QDebug>
#include <QTextStream>
static QTextStream cout (stdout,QIODevice::WriteOnly);
#include <iostream>
#include <QtGlobal>

void test()
{
qDebug() << "HelloWorld-qdebug";
cout << "Helloword-QTextStream" <<endl;
std::cout<<"Helloword-std::cout"<<std::endl;
}

void test_types()
{
qint8 signed_char_type;//signed char 有符号8bit
qint16 signed_short_type;//signed short 有符号16bit
qint32 signed_int_type;//signed int 有符号32bit
qint64 signed_long_long_int_type;//signed long long int 有符号64bit

qDebug() <<"sizeof(qint8)=" <<sizeof (signed_char_type)
<<"sizeof(qint16)=" <<sizeof (signed_short_type)
<<"sizeof(qint32)=" <<sizeof(signed_int_type)
<<"sizeof(qint64)=" <<sizeof (signed_long_long_int_type)<<endl;;

qptrdiff qint32_or_qint64_type;//32位系统 qint32 64位系统 qint64
qreal double_or_float_type;//默认是double,如果加上-qreal float选项,那么是float
qintptr same_as_qptrdiff;//32位系统 qint32 64位系统 qint64
quintptr quint32_or_quint64_type;//32位系统 quint32 64位系统 quint64
qDebug() <<"sizeof(qptrdiff)=" <<sizeof (qint32_or_qint64_type)
<<"sizeof(qreal)=" <<sizeof (double_or_float_type)
<<"sizeof(qintptr)=" <<sizeof(same_as_qptrdiff)
<<"sizeof(quintptr)=" <<sizeof (quint32_or_quint64_type)<<endl;

quint8 unsigned_char_type;//unsigned char 无符号8bit
quint16 unsigned_short_type;//unsigned short 无符号16bit
quint32 unsigned_int_type;//unsigned int 无符号32bit
quint64 unsigned_long_long_int_type;//unsigned long long int 无符号64bit
qDebug() <<"sizeof(quint8)=" <<sizeof (unsigned_char_type)
<<"sizeof(quint16)=" <<sizeof (unsigned_short_type)
<<"sizeof(quint32)=" <<sizeof(unsigned_int_type)
<<"sizeof(quint64)=" <<sizeof (unsigned_long_long_int_type)<<endl;

qlonglong same_as_qint64_type;//相当于qint64
qulonglong same_as_quint64_type;//相当于quint64
qDebug() <<"sizeof(qlonglong)=" <<sizeof (same_as_qint64_type)
<<"sizeof(qulonglong)=" <<sizeof (same_as_quint64_type)<<endl;

uchar unsigned_char_type_same_quint8;//unsigned char 无符号8bit
ushort unsigned_short_type_same_quint16;//unsigned short 无符号16bit
uint unsigned_int_type_same_quint32;//unsigned int 无符号32bit
ulong unsigned_long_type;//unsigned long 无符号32bit
qDebug() <<"sizeof(uchar)=" <<sizeof (unsigned_char_type_same_quint8)
<<"sizeof(ushort)=" <<sizeof (unsigned_short_type_same_quint16)
<<"sizeof(uint)=" <<sizeof(unsigned_int_type_same_quint32)
<<"sizeof(ulong)=" <<sizeof (unsigned_long_type)<<endl;

}

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
test();
test_types();
return a.exec();
}

标签:实战,Qt5.12,符号,int,数据类型,unsigned,long,signed,type
From: https://blog.51cto.com/remotedev/6132573

相关文章

  • Azure 基础架构现代化 -- 实战训练营
    在二月的最后一天,我们顺利的举办了Azure基础架构现代化--实战训练营!!本次实战训练营Agenda如下:主题时间方式状态基础架构现代化2023.2.1709:30~10:30Workshop已结束SQL......
  • 接口测试——电商网站接口测试实战(四)
    1.接口测试需求分析常见接口文档提供的两种方式①word文档②在线文档电商网站网址模拟练习:http://111.231.103.117:8083/swagger-ui.html2.登陆的分析慕慕生......
  • 【项目实战典型案例】16.消息队列作用和意义
    目录​​一:背景介绍​​​​二:消息队列​​​​消息队列简介​​​​解耦​​​​异步​​​​流量削峰​​​​原理​​​​1.ArrayBockingQueue:​​​​2.Socket​​​​3......
  • 【项目实战典型案例】21.面向对象复用、面向对象实现、立体化权限落地
    目录​​一:背景介绍​​​​1、针对于激励配置的功能体现出来的:面向对象的思想就可以实现极大程度的复用性的问题​​​​2、脱离学习通设计图,过程化,如何用面向对象的思想来......
  • Qt5.12实战之QByteArray与字符指针及字符串转换
    示例源码:#include<QCoreApplication>#include<QDebug>#include<QTextStream>staticQTextStreamcout(stdout,QIODevice::WriteOnly);#include<iostream>#include......
  • Qt5.12实战之字节数组QByteArray使用
    示例源码:#include<QCoreApplication>#include<QDebug>#include<QTextStream>staticQTextStreamcout(stdout,QIODevice::WriteOnly);#include<iostream>#inclu......
  • Halcon Dict字典数据类型获取键的值
    对于下面这个字典变量  要访问键‘classfication_class_ids’对应的值不能使用传统写法:DLResultBatch['classfication_class_ids']直接访问要使用get_dict_tuple函......
  • 数据类型之间的转换
    1#1.接收用户输入2num=input('请输入您的幸运数字:')34#2.打印结果5print(f"您的幸运数字是{num}")67#3.检测接收到的用户输入的数据类型--......
  • DDD实战(01)-概述
    程序设计语言指导怎样把设计更好地落地各种编程范式指导可以用什么样的元素去做设计设计原则与模式指导如何组合分解出来的各个元素分解组合的东西是从哪来?需要你对设计方法......
  • Presto-gateway 讲解与实战操作
    目录一、概述二、部署mysql三、部署多套presto集群四、部署presto-gateway与简单使用1)下载2)Maven编译3)修改配置4)sql初始化5)启动服务6)增加和修改presto集群1、通过CU......