2013-03-18 37 views

回答

2

看看QML Rotation項目。

您可以將旋轉原點設置爲您的下邊框中心的Rectangle,然後在x軸上旋轉。


編輯:

Rectangle { 
    id: myDock 
    width: 500 
    height: 50 
    color: "red" 

    transform: Rotation { 

    // Transform origin is the middle point of the lower border 
    origin { 
     x: myDock.width/2 
     y: myDock.height 
    } 

    axis {x: 1; y: 0; z: 0} 
    angle: 45 
    } 

} 
+0

你會這麼好心發佈的這一個代碼段。當我試圖像這個'origin.x:Item.Bottom'那樣設置旋轉原點時,只有矩形的右側正確旋轉。左側是正常的? – user889329 2013-03-21 09:23:47

+0

我在上面添加了一個例子 – 2013-03-21 11:38:23

+0

感謝TheHuge_。很好地工作,我錯過了將origin.y設置爲矩形(或圖像)的高度。 – user889329 2013-03-21 12:14:17