For a background of my application, see http://www.qtcentre.org/threads/2509...ht=#post121381
I have a function
void Client::readSocket()
{
block = tcpSocket->readAll();
m_DataEccentricity[0] = block[9];
m_DataEccentricity[1] = block[10];
m_DataEccentricity[2] = block[11];
m_DataEccentricity[3] = block[12];
convertToFloat();
...
}
void Client::readSocket()
{
QByteArray block;
block = tcpSocket->readAll();
m_DataEccentricity[0] = block[9];
m_DataEccentricity[1] = block[10];
m_DataEccentricity[2] = block[11];
m_DataEccentricity[3] = block[12];
convertToFloat();
...
}
To copy to clipboard, switch view to plain text mode
where
QByteArray m_DataEccentricity;
To copy to clipboard, switch view to plain text mode
Convert to float...
void Client::convertToFloat()
{
fl
= QString(m_DataEccentricity.
toHex());
//convert the data to string qint32 intValue = fl.toInt(0,16); //...and the string to an int
m_Eccentricity = *(float*)&intValue;
...
}
void Client::convertToFloat()
{
QString fl;
fl = QString(m_DataEccentricity.toHex()); //convert the data to string
qint32 intValue = fl.toInt(0,16); //...and the string to an int
m_Eccentricity = *(float*)&intValue;
...
}
To copy to clipboard, switch view to plain text mode
and in another function where I do updating of the GUI
eccentricityLineEdit
->setText
(QString::number(m_Eccentricity,
'f',
6));
eccentricityLineEdit->setText(QString::number(m_Eccentricity,'f',6));
To copy to clipboard, switch view to plain text mode
With regard to contents of my byte array, doing a
qDebug (DataEccentricity)
qDebug (DataEccentricity)
To copy to clipboard, switch view to plain text mode
gives "¾ _h", but that isn't a blank between 3/4 and _, it is supposed to be a vertical bar with a small bar midway up pointing to the right (like an "H" without the right bar)
Bookmarks