1

In a function property of an element with id: window, I create dynamic objects as follows:

Qt.createQmlObject(
    'import QtQuick 2.3; Rectangle {color: "#00FF00"; width: 1; anchors.right: '+i+'; height:1; anchors.bottom: '+i+'; }',
    window, "dynamicPixels");

where i is the iterating variable of a loop containing this snippet.

When I attempt to do some calculation with i, and use that as the value in the dynamic object, it complains:

Unexpected token: 'numeric literal'

I tried Math.round() thinking it might somehow have become double (even though the calculation involved only ints), but without change.

However, when I reduced the line to just i to make my post here clearer, I get the different error:

Invalid property assignment: unsupported type "QQuickAnchorLine"

So do I have deeper problems - can I not use anchors at all in a dynamic object?

1 Answer 1

4

You want anchors.rightMargin. anchors.right is for anchoring to items by ID.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.