View Full Version : Visual Studio 2010 Conditional Breakpoint + QString

24th April 2012, 11:25
Hello, I am using visual studio 2010 and Qt 4.8. I read this article regarding conditional breakpoints and std:string

Is it possible to achieve the same with a QString? It seems that breakpoint isn't activated when I set a codition regarding a specific value of a QString variable. For example I want to set a breakpoint to stop if variable aa = "test".

1st May 2012, 17:11
Any help on that?

2nd May 2012, 02:00
if the you can't do aa == "test" maybe you can try to use wsccmp((const wchar_t*)aa.utf16(), L"test") == 0 like in the exemple
(i always work with unicode but you can use strcmp())

2nd May 2012, 09:46
I doubt it will work because the only method evaluation that is supported are mentioned in the article. Using methods on QString (e.g. utf16()), therefore, I believe wont work. You would have to directly access the data pointer in QString.

2nd May 2012, 14:13
you mean like :

wchar_t* str_ptr = (const wchar_t*)aa.utf16();
and then put the breakpoint test to :
wsccmp(str_ptr, L"test") == 0;

2nd May 2012, 19:18
That isn't what you said in your previous post. I was stating my doubt that

wsccmp((const wchar_t*)aa.utf16(), L"test") == 0

would work due to utf16() method.

2nd May 2012, 19:37
oh but that work i m sure of it
utf16() retrun the wide char pointer to the qstring

2nd May 2012, 22:56
It appears you are missing my point again. My point being that visual studio wont support it on a break line conditional.
(my untested belief based on the fact MS are very happy to shout about supporting basic string free functions)