2

从 javascript 使用创建对象后:

function createNextItem(item, where) {
    component = Qt.createComponent(val);
    sprite = component.createObject(where, {
                                    "id": "currentitem",
                                    "anchors.left": nextlabel.right,
                                    "anchors.leftMargin": units.gu(4),
                                    "anchors.verticalCenter": nextlabel.verticalCenter
                                });

    if (sprite === null) {
        // Error Handling
        console.log("Error creating object");
    }
}

如果我尝试添加"transform": Scale { xScale: 0.5 ; yScale: 0.5}我得到一个SyntaxError: Unexpected token {但如果我做这样的事情"transform": "Scale { xScale: 0.5 ; yScale: 0.5}",它不起作用......有什么帮助吗?

4

1 回答 1

2

Never mind... i got it by making a container parent item, scaling it and then creating the new object in it, something like this:

Item {
    id: currentitem
    transform: Scale { xScale: 0.5; yScale: 0.5}
    Component.onCompleted: { Jsfile.createItemObjects(ChkItem.getCurrentItem(), currentitem)
        }
    }
于 2013-03-24T01:03:15.303 回答