QDataStream serialze & deserialize 'myclass' pointer
-
@kshegunov good :))
Now there are new problems.
Recently everything was good.
I do not know what happened to me or why.C:\Users\User\Desktop\tazsmsorigin\enumeration.h:69: error: no match for 'operator>>' (operand types are 'QDataStream' and 'qint32 {aka int}') stream >> tempint; _class.UID = tempint; ^ C:\Users\User\Desktop\tazsmsorigin\enumeration.h:50: error: ambiguous overload for 'operator<<' (operand types are 'QDataStream' and 'int') stream << static_cast<qint32>(_class.UID) ^ C:\Users\User\Desktop\tazsmsorigin\enumeration.h:46: error: no match for 'operator>>' (operand types are 'QDataStream' and 'bool') return stream >> _class.TChecked >> _class.Message; ^
Did you forget to include the
<QDataStream>
header? -
@kshegunov no. I have
-
@kshegunov no. I have
Then you need to follow the compiler errors, it has given you exact directions where the errors are:
C:\Users\User\Desktop\tazsmsorigin\enumeration.h @ line 69error: no match for 'operator>>' (operand types are 'QDataStream' and 'qint32 {aka int}')
I'm pretty sure this comes from not including the header. Also there's something amiss, it should be
QDataStream &
notQDataStream
. Please post what's on line 69 inenumeration.h
. -
Then you need to follow the compiler errors, it has given you exact directions where the errors are:
C:\Users\User\Desktop\tazsmsorigin\enumeration.h @ line 69error: no match for 'operator>>' (operand types are 'QDataStream' and 'qint32 {aka int}')
I'm pretty sure this comes from not including the header. Also there's something amiss, it should be
QDataStream &
notQDataStream
. Please post what's on line 69 inenumeration.h
.@kshegunov
Yes the library was nat included, but I had it in globaldefines.h file.
He has caused a redifination proxy, QDataStream also has been described in MySocket.h file. -
@kshegunov
Yes the library was nat included, but I had it in globaldefines.h file.
He has caused a redifination proxy, QDataStream also has been described in MySocket.h file.@Taz742 said in QDataStream serialze & deserialize 'myclass' pointer:
He has caused a redifination proxy, QDataStream also has been described in MySocket.h file.
I don't follow.
-
@Taz742 said in QDataStream serialze & deserialize 'myclass' pointer:
He has caused a redifination proxy, QDataStream also has been described in MySocket.h file.
I don't follow.
@kshegunov I had code again mysocket.h, I taught at different places how to deal with my classes.
-
@Taz742 said in QDataStream serialze & deserialize 'myclass' pointer:
He has caused a redifination proxy, QDataStream also has been described in MySocket.h file.
I don't follow.
@kshegunov @VRonin
How to handle QDataStream to my classes, this are stored in one 'header' file.
It's uncomfortable for me because I have many issues.
I learnt to my classes QDataStream >> and << operators.For Example:
#ifndef POINT3D_H #define POINT3D_H #include "QObject" #include "QDataStream" class Point3D { public: Point3D(); int x; int y; int z; Point3D(int _x, int _y, int _z) { this->x = _x; this->y = _y; this->z = _z; } friend QDataStream & operator << (QDataStream &stream, const Point3D &obj); friend QDataStream & operator >> (QDataStream &stream, Point3D &obj); }; Q_DECLARE_TYPEINFO(Point3D, Q_MOVABLE_TYPE); #endif // POINT3D_H
#include "point3d.h" Point3D::Point3D() { } QDataStream & operator << (QDataStream &stream, const Point3D &obj) { stream << static_cast<qint32>(obj.x) << static_cast<qint32>(obj.y) << static_cast<qint32>(obj.z); return stream; } QDataStream & operator >> (QDataStream &stream, Point3D &obj) { qint32 tempint; stream >> tempint; obj.x = static_cast<int>(tempint); stream >> tempint; obj.y = static_cast<int>(tempint); stream >> tempint; obj.z = static_cast<int>(tempint); return stream; }
I want to be sure that this will work from anywhere. Can you confirm it?
-
@kshegunov @VRonin
How to handle QDataStream to my classes, this are stored in one 'header' file.
It's uncomfortable for me because I have many issues.
I learnt to my classes QDataStream >> and << operators.For Example:
#ifndef POINT3D_H #define POINT3D_H #include "QObject" #include "QDataStream" class Point3D { public: Point3D(); int x; int y; int z; Point3D(int _x, int _y, int _z) { this->x = _x; this->y = _y; this->z = _z; } friend QDataStream & operator << (QDataStream &stream, const Point3D &obj); friend QDataStream & operator >> (QDataStream &stream, Point3D &obj); }; Q_DECLARE_TYPEINFO(Point3D, Q_MOVABLE_TYPE); #endif // POINT3D_H
#include "point3d.h" Point3D::Point3D() { } QDataStream & operator << (QDataStream &stream, const Point3D &obj) { stream << static_cast<qint32>(obj.x) << static_cast<qint32>(obj.y) << static_cast<qint32>(obj.z); return stream; } QDataStream & operator >> (QDataStream &stream, Point3D &obj) { qint32 tempint; stream >> tempint; obj.x = static_cast<int>(tempint); stream >> tempint; obj.y = static_cast<int>(tempint); stream >> tempint; obj.z = static_cast<int>(tempint); return stream; }
I want to be sure that this will work from anywhere. Can you confirm it?
@Taz742 said in QDataStream serialze & deserialize 'myclass' pointer:
I want to be sure that this will work from anywhere. Can you confirm it?
I don't understand the question, could you elaborate.
-
@Taz742 said in QDataStream serialze & deserialize 'myclass' pointer:
I want to be sure that this will work from anywhere. Can you confirm it?
I don't understand the question, could you elaborate.
@kshegunov said in QDataStream serialze & deserialize 'myclass' pointer:
I don't understand the question, could you elaborate.
I have class Point3D which know how to behave when datastream requires input(<<) or output(>>) operators.
I want to know if it will works from anyclasses, for example: from mainwindows and etc.. -
@kshegunov said in QDataStream serialze & deserialize 'myclass' pointer:
I don't understand the question, could you elaborate.
I have class Point3D which know how to behave when datastream requires input(<<) or output(>>) operators.
I want to know if it will works from anyclasses, for example: from mainwindows and etc..Why wouldn't it? As long as the functions have declarations at the point of usage it's the linker's problem to tie it all together ... it's the singular purpose for which the linker exists actually.
-
Why wouldn't it? As long as the functions have declarations at the point of usage it's the linker's problem to tie it all together ... it's the singular purpose for which the linker exists actually.
@kshegunov Now I'm sure. thanks.