c++ - Qt-how to convert a QByteArray to struct -
i need convert qbytearray structure. have construction :
struct mavlink_attitude_t { /// <summary> timestamp (milliseconds since scheme boot) </summary> quint32 time_boot_ms; /// <summary> roll angle (rad, -pi..+pi) </summary> float roll; /// <summary> pitch angle (rad, -pi..+pi) </summary> float pitch; /// <summary> yaw angle (rad, -pi..+pi) </summary> float yaw; /// <summary> roll angular speed (rad/s) </summary> float rollspeed; /// <summary> pitch angular speed (rad/s) </summary> float pitchspeed; /// <summary> yaw angular speed (rad/s) </summary> float yawspeed; };
and have qbytearray comes serial port. used union think can't used qbytearray. there other way? illustration can help! tanks.
you can cast it:
qbytearray arr; mavlink_attitude_t* m = reinterpret_cast<mavlink_attitude_t*>(arr.data());
c++ qt data-structures struct qbytearray
No comments:
Post a Comment