Jabu
Jabu

Reputation: 132

How to make Visual Studio evaluate Qt expressions?

Whatever Qt expression i try to evaluate while debugging on Visual Studio 2022 doesnt work, for example:

5d011f70-9098-48bd-8def-c2da4ffdd35f-image.png

  1. Conditional breakpoints with Qt expressions doesnt work.
  2. Any Qt expression on watch window always: Function QWidget::height has no address, possibly due to compiler optimizations.

I'm on Debug mode, i also tried:

C/C++ > Optimization -> Optimization -> Disabled /Od

And also all options here:

316fb1b1-ee66-4e2d-bfa3-9839c6daf8a2-image.png

I'm using Qt 6.6, VS22 latest version available today.

Upvotes: 0

Views: 73

Answers (1)

3CxEZiVlQ
3CxEZiVlQ

Reputation: 38863

Often inline functions are inline even in the Debug configuration.

Navigate to QtWidget::height() source to see

inline int QWidget::height() const
{ return data->crect.height(); }

Set a condition on w.data->crect.height().

If there's no success yet, repeat the condition expansion with crect.height() that will be like w.data->crect.y2 - w.data->crect.y1 + 1.

Upvotes: 0

Related Questions