c++ - Qt-how to convert a QByteArray to struct -


I need to convert a QByteArray into a structure. I have such a structure:

  struct mavlink_attitude_t {/// & lt; Summary & gt; Timestamp (millisecond from system boot) & lt; / Summary & gt; Quint 32 Time_boot_ms; /// & lt; Summary & gt; Roll angle (rad, -pi .. + pi) & lt; / Summary & gt; Float roll; /// & lt; Summary & gt; Pitch angle (red, -p + + pi) & lt; / Summary & gt; Boat pitch; /// & lt; Summary & gt; Angle of O (Red, -P. + Pi) & lt; / Summary & gt; Float yao; /// & lt; Summary & gt; Angular Speed ​​Roll (Rod / S) & lt; / Summary & gt; Float rollspeed; /// & lt; Summary & gt; Pitch angular momentum (rad / s) & lt; / Summary & gt; Float pitchspid; /// & lt; Summary & gt; Yoga's angular momentum (RD / S) & lt; / Summary & gt; Float Yspeed; };  

And I come from a Quetbeat Serial Port. I was already using the union but I think it can not be used for QByteArray, is there any other way? An example can really help! Tank

You can enter:

  QByteArray arr; Mavlink_attitude_t * m = reinterpret_cast & lt; Mavlink_attitude_t * & gt; (Arr.data ());  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -