Qdebug display hex value

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

    int value = 0xff005542;
    qDebug() << QString("%1").arg(value , 0, 16).toUpper();
    

    >>> FF005542

    That'll give you hex output at whatever length is required. But if you'd like fixed width output, this is handy (example of four hex digits):

    int value = 0xff;
    qDebug() << QString("%1").arg(value, 4, 16, (QChar)'0').toUpper();
    //      Here's the fixed field length⬆︎
    

    >>> 00FF

提交回复
热议问题