I am trying to display a number using QDebug in the Hex format. Below is the code which I have written. It is working but the output has string contents enclosed in double quotes:
How to remove these quotes?
m_CanMsg_ptr->id = 0x720;
m_CanMsg_ptr->sizeData = 1;
m_CanMsg_ptr->data[0] = 0x05;
MessageID.setNum(m_CanMsg_ptr->id,16);
DataSize = QString("%1").arg(m_CanMsg_ptr->sizeData, 0, 16);
data = QString("%1").arg(m_CanMsg_ptr->data[0], 0, 16)
qDebug() << "Heart-Beat : Msg ID = " << MessageID << " Msg DLC = " << DataSize;
qDebug() << "Msg Data " << " = " << data;
I did as per these resources:
http://forum.qt.io/topic/5003/moved-how-to-display-a-local-variable-in-hex-when-debugging-a-qt-app/2 http://qt.shoutwiki.com/wiki/Convert_hexadecimal_to_decimal_and_vice-versa_in_Qt
The solution is simple:
#include <QDebug>
int value = 0x12345;
qDebug() << "Value : " << hex << value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With