[moved] how to display a local variable in hex, when debugging a qt app
-
Hi ,
This should be a simple issue however I did not find the way to solve it for several days.I am debugging a qt application and when I add local variables they all come in decimal form. My application is a low level one and to understand the results I need hexadecimal / hex results.
Is this possible in qt?
If possible - how do I set the debugger to display in hex?Thank you,
Paul. -
Hello Volker,
Thank you for the quick replay.Certainly I can place a hex output - as a printf(), a messagebox, or qDebug , however the code will be 2-3 times the current size, just to get some info how it executes.
I need to give some details -
I am using qtcreator to build and debug an application.
I start the app in debug mode - there are several areas showing functions, and next to them local variables and adding watch variables.
Some of the functions come with hex addresses , however the locals and watches are decimal.
The same is when I point the cursor to get info on variable as a tooltip.My question is how do I get this info as hex and not decimal?
If this is not currently possible in 'qt' - it means that for the last 10-15 years it has not been used in low level development , and nobody did raise the issue with the development team.
Thank you,
Paul. -
[quote author="paa123456" date="1302476516"]Hello Volker,
If this is not currently possible in 'qt' - it means that for the last 10-15 years it has not been used in low level development , and nobody did raise the issue with the development team.[/quote]Qt Creator, which you seem to be talking about, has indeed not been used for the last 10-15 years. For any kind of development. It is only a few (two or so?) years old, after all.
The tools Qt builds on (compilers, debuggers, etc.) have existed for the time span you're talking about, and can probably do all you need it to do.
-
Wouldn't be
@int x = 14948;
qDebug() << "x = " << x << " = " << std::hex << x;
@easier?
[quote author="Volker" date="1302472389"]This does the trick:
@
int x = 14948;
QString xAsHex = QString("%1").arg(x, 0, 16);
qDebug() << "x = " << x << " = " << xAsHex;
// output:
// x = 14948 = "3a64"
@[/quote] -
[quote author="JohanSolo" date="1302510723"]Wouldn't be
@int x = 14948;
qDebug() << "x = " << x << " = " << std::hex << x;
@easier?
[/quote]No, it's output is
@
// x = 14948 = true 14948
@But this does the trick too:
@
// no std:: before the hex
qDebug() << "x1 = " << x << " = " << hex << x;
@ -
[quote author="paa123456" date="1302476516"]
I need to give some details -
I am using qtcreator to build and debug an application.
I start the app in debug mode - there are several areas showing functions, and next to them local variables and adding watch variables.
Some of the functions come with hex addresses , however the locals and watches are decimal.[/quote]It would be helpful, if you gave those informations in the first place. The crystal ball is out of work on weekends, you know :-) Qt is not Qt Creator. You can use the first without the second. We would have given you the right solution directly.
The way peppe described works.
-
peppe wrote -
Can’t you just rightclick on the local you’re interested in and set its format to hexadecimal?
Yes, rightclick 'change format for type' does work in qtcreator - however for basic types only.
If I have -
#define DWORD unsigned int
the right click 'change format for type' for DWORD watch/variable is disabled in qtcreator.
Is there a way to make it working for defined types?Well , at least I got something to help with debugging.
Thank you ,
Paul.