Multiline String Formatting
-
What is the recommended way to handle multiline strings in QML source code? I have some examples of elements with long static text strings. They look vaguely like the following. Some of the descriptions can get quite long and take up several lines when wrapped. If I was writing C code, and using a tool like Clang-Format, this would automatically get wrapped and formatted. However the QML formatter (QtCreator -> "Tools" -> "QML/JS" -> "Reformat file") doesn't do this. Its annoying to work with or review long strings like this in code review if they're not wrapped. And its a pain to manually mess with string concatenation operators, parentheses, newlines every time we add or modify a long string.
So am I doing this wrong? Should I be storing these strings somewhere else or writing my code in a different way? If this is the recommended way, is there any means of formatting this?
CustomItem { title: qsTr("Setting") description: qsTr("Adjusting this value will change some setting. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Long static text description.") value: 0 }
Edit: To clarify, I am strictly asking about how to format my source code. The text gets wrapped perfectly fine in the actual application at runtime.
-
@stewythe1st Did you find any solution to this? I find it ridiculous that QML seemingly lacks the tools to format multiline strings in the source code.
Using string concatenation (
"string" + "string"
…) works but is unbeliavably cumbersome.