Qdebug display hex value

前端 未结 9 1462
你的背包
你的背包 2021-02-19 02:56

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 quot

9条回答
  •  梦如初夏
    2021-02-19 03:32

    qDebug is a debug interface. It's not meant for custom-formatted output, it's simply a way of quickly getting data in readable form. It's meant for a developer, and the quotes are there to remind you that you've output a string. qDebug() presumes that the const char* data is a message and shows it without quotes, other string types like QString are "just data" and are shown with quotes.

    If you want custom formatting, don't use qDebug(), use QTextStream:

    #include 
    #include 
    
    QTextStream out(stdout);
    
    void f() {
       out << "Heart-Beat : Msg ID = " << MessageID << "  Msg DLC = " << DataSize << endl;
    }
    

提交回复
热议问题