In Qt, QFile, QByteArray, QDataStream and QTextStream are commonly used file and data processing classes. Main functions and differences QFile: QFile is an I/O device used to read and write text and binary files and resources. You can use QFile on its own, or more conveniently with QTextStream or QDataStream. The file name is usually […]
Tag: bytea
QByteArray byte array
QByteArray byte array Article directory QByteArray byte array 1.1 Basic instructions for using the QByteArray class 1.2 Set the array byte size 1.3 Return array size 1.4 Convert data to other types 1.5 Convert data to character pointer in C language and return 1.6 Array data appending 1.7 Clear array data to specified value 1.8 […]
Conversion between strings (char*, const char*, char[], string, QString, QByteArray, int, double)
Table of Contents 1. Several methods to apply for space: 1. C language 2.C++ 2. Conversion of each string 1. char* and unsigned char*, char* and const char*, char* and char[ ] 2. string and char*, string and unsigned char*, string and QString, string and int, double 3. QString and int, double, QString and char* […]
Implement Java’s ByteArray class (byte array) in C++
Recently, due to project reasons, it is necessary to implement the ByteArray class in the Java project with C++, so I thought about it for a while. The following is the description of some of the implemented methods in this class: // Add a byte to ByteArray. void addByte(uint8_t byte); // Add multiple bytes to […]
[Qt] QString, QByteArray, char* are converted to each other.
This article mainly explains the mutual conversion between QString, QByteArray, and char*. There may be many ways, and the methods in this article are only part of them. Because sometimes it is necessary to display hexadecimal data in the control, it involves the conversion between hexadecimal data and strings, so the string containing hexadecimal format […]
The method of converting between QString and QByteArray
The method of converting between QString and QByteArray [1] The method of converting between QString and QByteArray QString to QByteArray method QByteArray to QString method The QByteArray class also does not end with ‘\0’ QByteArray to QString, mainly use buf.toHex() [2] Data conversion problem in Qt development serial communication software 1. Read serial port commands […]
Qt5.12 actual QByteArray and character pointer and string conversion
Sample source code: #include <QCoreApplication> #include <QDebug> #include <QTextStream> static QTextStream cout (stdout,QIODevice::WriteOnly); #include <iostream> #include <QtGlobal> #include <QByteArray> 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 signed 8bit qint16 signed_short_type;//signed short signed 16bit qint32 signed_int_type;//signed int signed 32bit qint64 signed_long_long_int_type;//signed long long int signed […]