Petr
Petr

Reputation: 14485

How to display whole QString while debugging

I am using Qtcreator and always when I need to display large string, it's trimmed, see screenshot: enter image description here

Is there any way to display whole QString? Note that using Open view contents in editor doesn't help either, it's same there.

Upvotes: 12

Views: 4979

Answers (6)

Jax297
Jax297

Reputation: 657

Right-clicked on the "class Qstring" under "Value", then selected "Change value display format" -> "Treat all characters as printable"

Upvotes: 0

Pierre
Pierre

Reputation: 4416

None of the above change that a QString is displayed simply as an address, along with all its useless cryptic members.

However, if you right-click on the variable in the debugging panel, and click on "Use Debugging Helpers", all the contents of the string are displayed. Hoorah.

Upvotes: 0

Sergey Lobanov
Sergey Lobanov

Reputation: 21

This is the best answer: https://stackoverflow.com/a/52298088/9256941

"In Local and Expressions, right click on the variable and click on Change Value Display Format, then under Change Display for type QString click on Separate Window"

Upvotes: 2

RDK
RDK

Reputation: 108

Seems to be a limitation of the Qt Creator UI that cuts the displayed length of strings.

qDebug() << yourString; seems to work for me, I can see my whole string in the application output panel :-)

Upvotes: 1

user3779331
user3779331

Reputation: 291

There is a setting under "Tools -> Options -> Debugger -> (Locals & Expressions or General (depending on your creator version))" that limits the string length to default 10000 characters.

Upvotes: 15

You're right, I tried on my machine with a 150000 characters string and the same happened... It seems that qDebug() has the same limitation. I would suggest you to output your string to a file, using fstream for example.

Upvotes: 0

Related Questions