Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-02 11:11:38 09月29日 Update

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 ()

Tags: Data files buffers directories text buffers examples data streams content differences signals versions articles types devices monitoring auxiliary analysis binary code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology Xiaomi MySQL Redmi