Qdebug display hex value

前端 未结 9 1507
你的背包
你的背包 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:48

    May be a little late, but in case someone needs this:

    As statet in the answere by Kuber Ober, Qt only removes the quotes if it's a const char * passed to qDebug. However, Qt provides a macro to do the same with a QString - The qPrintable macro:

    qDebug() << qPrintable(QString("String without quotes")) << QString("String with quotes");
    

    This way, you can use the QString::number function (as provided by TheDancinZerg) to format the string:

    int value = 0xFFFF;
    qDebug() << qPrintable(QString::number(value, 16));
    

提交回复
热议问题