Rectangle{} debugging in QML – like printf(), but for QT
raymii.org
raymii.org
I implement a lot of QML (with C++ viewModels to back it).
My UI designer actually issued a challenge to me, to see if I could get "Debug Rectangles" to toggle on-and-off without a rebuild. I'm so grateful for that challenge, because once the seed of the idea was planted, my thirst for this "nice-to-have" feature grew until I couldn't NOT solve it.
I now have:
``` DebugRectangle{} ```
https://github.com/219-design/qt-qml-project-template-with-c...
... which I place inside any item that needs a highlight. I then leave this code in place (nothing to comment-in/comment-out).
I hijack an environment variable for the toggle. The icing on the cake was seeing that this works both when running a compiled binary executable ("my Qt/QML app binary") and when viewing my QML with just qmlscene. https://github.com/219-design/qt-qml-project-template-with-c...
Qt Creator still has the form designer (NOT the debugger as mentioned in the post) that can be brought up on any component. It's not optimal either, but it's better than modifying item scalars by hand.
The forms designer does not work if you use qrc:/ includes or inline javascript, plus it generates ugly code (and uses hard x / y positions instead of anchors).