26 novembre 2011
1/31
2/31
import QtQuick 1.0
Rectangle {
    width: 200
    height: 150
    Text {
        anchors.centerIn: parent
        text: "Hello World"
    }
}
3/31
Les éléments fournient avec QML sont très simples. Les plus communs sont :
4/31
La taille d'un élément n'est pas limitée par la taille de son parent !
import QtQuick 1.0
Rectangle {
    width: 200
    height: 150
    Rectangle {
        width: 10
        height: 40
        color: "green"
        anchors.centerIn: parent
        Text {
            anchors.centerIn: parent
            text: "Hello World"
        }
    }
}
5/31
6/31
7/31
Rectangle {
    width: 250
    height: 200
    Rectangle {
        id: topLeftRect
        color: "red"
        anchors.left: parent.left
        anchors.top: parent.top
        width: 40
        height: 40
    }
    Rectangle {
        id: bottomRect
        color: "green"
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        height: 40
    }
}
8/31
    //...
    Rectangle {
        color: "black"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: topLeftRect.bottom
        width: 40
        height: 40
    }
    Rectangle {
        color: "blue"
        anchors.left: topLeftRect.right
        anchors.leftMargin: 10
        anchors.top: parent.top
        anchors.topMargin: 10
        anchors.bottom: bottomRect.verticalCenter
        width: 40
    }
    //...
9/31
10/31
11/31
onClickedonEnteredonExited12/31
pressedpressedButtonscontainsMouse13/31
14/31
15/31
16/31
Square.qml
Rectangle {
    color: "blue"
    width: 40
    height: width
    radius: 7
}
Code utilisant le composant Square :
Rectangle {
    width: 200
    height: 150
    Square {
        x: 10
        y: 10
    }
    Square {
        x: 60
        y: 10
    }
    Square {
        x: 10
        y: 60
        color: "red"
    }
}
17/31
Permettent de signaler au monde extérieur que quelque chose c'est produit.
MyComponent.qml
Item {
    signal activated // Définition
    MouseArea {
        onClicked: myItem.activated() // Emission
        ...
    }
}
Item {
    MyComponent {
        onActivated: { /* Code JS à exécuter */ }
    }
}
18/31
Syntaxe : property <type> <nom>[: <valeur>]
MyComponent.qml
Item {
    property int length: 20 // Définition
    Rectangle {
        width: myItem.length + 4 // Utilisation
        ...
    }
}
Item {
    MyComponent {
        length: 30
    }
}
19/31
Permettent d'exposer une propriété d'un élément enfant
Syntaxe : property alias <nom>: <enfant.propriété>
Item {
    property alias color: rect.color
    Rectangle {
        id: rect
        ...
    }
}
Item {
    MyComponent {
        color: "red"
    }
}
20/31
Calculatrice minimaliste
21/31
22/31
Plusieurs façons d'appliquer des animations
23/31
24/31
25/31
26/31
27/31
28/31
29/31
30/31
31/31
| Table of Contents | t | 
|---|---|
| Exposé | ESC | 
| Full screen slides | e | 
| Presenter View | p | 
| Source Files | s | 
| Slide Numbers | n | 
| Toggle screen blanking | b | 
| Show/hide slide context | c | 
| Notes | 2 | 
| Help | h |