Code c(*dataPtr);v = qVariantFromValue(c); Code code = v.value<Code>();
if (n != -1) buf_r[n] = '\0';
C++ (Qt)class Code {public: Code() {} Code(const Code &code) { data = code; } Code(unsigned char ch) { data = ch; } operator unsigned char() const { return data & 0x1f; } protected: unsigned char data;}; Q_DECLARE_METATYPE(Code); QDataStream &operator << (QDataStream &out, const Code &code);QDataStream &operator >> (QDataStream &in, Code &code);
for (qint64 i = 0; i < len; i++) { qint64 n = port->read((char*)&buf_r, 1024); // вычитать из буфера содержимое if (n <= len) .....