Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Qt text flow and data flow, buffer Operation and data Operation

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you Qt Chinese text flow and data flow, buffer operation and data operation example analysis, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

one。 Text flow and data flow

In A.Qt, file types are divided into two categories.

1. Text file-the content of the file is a readable text character

two。 Data file-the content of the file is direct binary data

QFile directly supports reading and writing of text files and data files.

B.Qt provides helper classes to simplify the reading and writing of text / data files

1. QTextStreamMouse-all written data is converted to readable text

2.QDataStreammusic-the data written is converted to binary data according to type

How to use the IO device helper class

Different Qt versions may have different data stream file formats

Version number set by void setVersion (int v) / /

Int version () const// gets the read-write version number

Code example

# include # include # include int main (int argc, char * argv []) {QCoreApplication a (argc, argv); QFile file ("C:/Users/59673/Desktop/test.hex"); if (file.open (QIODevice::WriteOnly)) {QString dt = "mylovedandanxiaohai"; double value = 3.14; file.write (dt.toStdString (). C_str ()) File.write (reinterpret_cast (& value), sizeof (value); file.close ();} if (file.open (QIODevice::ReadOnly)) {QString dt = "; double value = 0; dt = QString (file.read (19)); file.read (reinterpret_cast (& value), sizeof (value)); file.close (); qDebug () b QDebug () pi; qDebug ()

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report