我想使用QDebug以十六进制格式显示一个数字。以下是我的代码。它可以工作,但输出结果中字符串的内容被双引号包围:
如何去掉这些引号?
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;
我按照以下资源的方法进行操作:
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
+
操作符而非<<
来拼接字符串了吗? - Sebastian Lange