2016-11-09 33 views
0

我開始在Qt Creator中編寫一個NumberAnimation聲明,並在自動填充框中獲得了幾件東西。其中之一是「數字動畫與目標」。這是否意味着有語法如下:QML:「NumberAnimation with foo」語法 - 這是什麼意思?

NumberAnimation with foo { 
    // ... 
} 

,我想我也看到了之前使用這個語法,但我不記得是什麼呢,既不這兩個Qt的文檔頁面:[1][2]似乎提到它。

回答

5

您得到的自動完成建議是創作者內置的snippets之一。如果您選擇的選項(通過點擊輸入,例如),你會得到這樣的代碼:

NumberAnimation { 
    target: object 
    property: "name" 
    duration: 200 
    easing.type: Easing.InOutQuad 
} 

您也可以看到代碼的預覽,它將在工具提示擴展到向右自動完成彈出窗口。

我想我也看到了這句法之前使用[...]

你想的語法大概是<Animation> on <Property>

import QtQuick 2.0 

Rectangle { 
    id: rect 
    width: 100; height: 100 
    color: "red" 

    PropertyAnimation on x { to: 100 } 
    PropertyAnimation on y { to: 100 } 
} 
1

對我來說,「數動畫與目標「片段生成以下存根:

NumberAnimation { 
    target: object 
    property: "name" 
    duration: 200 
    easing.type: Easing.InOutQuad 
    } 

IMO並不意味着有with的使用格式。此外,使用with實際上會導致語法錯誤。所以它看起來不像是一件事情。