当前位置:网站首页>Qt内存映射
Qt内存映射
2022-06-25 13:16:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
最近在看代码的时候发现了Qt的内存映射,原来只知道MFC有内存映射机制,可以在读取大数据文件时节约读取的时间,原来Qt中也有相应的机制,其用法更简单,下面用一个小例子演示其用法
#include <QtCore/QCoreApplication>
#include <QFile>
#include <QDebug>
#include <iostream>
#include <stdio.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile file("1.txt");
file.open(QIODevice::ReadWrite);
qDebug() << QStringLiteral("内存大小:") << file.size();
uchar *fpr = file.map(0, file.size());
int i = 0;
int x1 = 0, x2 = 0, x3 = 0;
char *pEnd1 = NULL;
char *pEnd2 = NULL;
char *pEnd3 = (char *)fpr;
for (int i = 0 ; i < 3 ; ++i)
{
x1 = strtod(pEnd3, &pEnd1);
x2 = strtod(pEnd1, &pEnd2);
x3 = strtod(pEnd2, &pEnd3);
std::cout << x1 << "," << x2 << "," << x3 << "\n";
}
file.close();
return a.exec();
}发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151691.html原文链接:https://javaforall.cn
边栏推荐
- Is it safe for Guosen Securities to open an account?
- Rust, the best choice for programmers to start a business?
- 【开源鸿蒙系统展示】RK3568开发板搭载OpenHarmony 3.1 Release
- Germany holds global food security Solidarity Conference
- When the input tag type is number, the input of E, e, -, + is blocked
- On the compatibility of the disabled attribute of input on the mobile terminal
- OpenStack学习笔记(二)
- Discuz copy today's headlines template /discuz news and information business GBK template
- 關於數據在內存中的存儲下
- Syntax 'trap'
猜你喜欢

關於一道教材題的講解

AGCO AI frontier promotion (6.25)

How to determine if a web worker has been created or closed

[pit avoidance means "difficult"] the antd form dynamic form is deleted, and the first line is displayed by default

Uncover gaussdb (for redis): comprehensive comparison of CODIS

Some knowledge about structure, enumeration and union
Deep parsing and implementation of redis stream advanced message queue [10000 words]

数据在内存中的存储相关内容

“移动云杯”算力网络应用创新大赛火热报名中!

Where can the brightness of win7 display screen be adjusted
随机推荐
How to determine if a web worker has been created or closed
Websocket -- reverse proxy to solve cross domain problems
JS prototype. slice. call(arguments); Convert pseudo array to array
NR-ARFCN和信道栅格、同步栅格和GSCN
QT mouse tracking
Download File blob transcoding
多台云服务器的 Kubernetes 集群搭建
Go--- route filter
关于三子棋游戏的简易实现与N子棋胜利判断方法
Syntax 'trap'
多臺雲服務器的 Kubernetes 集群搭建
Prototype relationship between constructor and instance (1)
Which Chinese virtual human is better? Sullivan, IDC: Xiaobing Baidu Shangtang ranks in the first echelon
AGCO AI frontier promotion (6.25)
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
数据采集系统网关采集工厂效率
On the realization of guessing numbers game
戴尔电脑cpu温度过高怎么办
KVM script management - the road to dream
OpenStack-----Nova源码分析之创建虚拟机