1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
import Qt 4.6
pragma Singleton
// some random qml snippets stolen from the qt docs
Rectangle <beginfold id='1'>{</beginfold id='1'>
important: true
propertyAsdf:
id: container
signalA: bla
property string label
signal clicked
radius: 5; border.color: "black"
color: mouse.pressed ? "steelblue" : "lightsteelblue"
gradient: Gradient <beginfold id='1'>{</beginfold id='1'>
GradientStop <beginfold id='1'>{</beginfold id='1'> position: mouse.pressed ? 1.0 : 0.0; color: "steelblue" <endfold id='1'>}</endfold id='1'>
GradientStop <beginfold id='1'>{</beginfold id='1'> position: mouse.pressed ? 0.0 : 1.0; color: "lightsteelblue" <endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
MouseRegion <beginfold id='1'>{</beginfold id='1'> id: mouse; anchors.fill: parent; onClicked: container.clicked() <endfold id='1'>}</endfold id='1'>
Text <beginfold id='1'>{</beginfold id='1'> anchors.fill: parent; text: container.label; anchors.centerIn: parent <endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
Rectangle <beginfold id='1'>{</beginfold id='1'>
Script <beginfold id='1'>{</beginfold id='1'>
function calculateMyHeight() <beginfold id='1'>{</beginfold id='1'>
return Math.max(otherItem.height, thirdItem.height);
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
anchors.centerIn: parent
width: Math.min(otherItem.width, 10)
height: calculateMyHeight()
color: <beginfold id='1'>{</beginfold id='1'> if (width > 10) "blue"; else "red" <endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
Rectangle <beginfold id='1'>{</beginfold id='1'>
default property color innerColor: "black"
property color innerColor: "black"
property alias text: textElement.text
property alias aliasXYZ: testElement.text
signal bar
signal bar(var blah, string yxcv)
width: 240; height: 320;
width: 100; height: 30; source: "images/toolbutton.sci"
ListView <beginfold id='1'>{</beginfold id='1'>
anchors.fill: parent
model: contactModel
delegate: Component <beginfold id='1'>{</beginfold id='1'>
Text <beginfold id='1'>{</beginfold id='1'>
text: modelData.firstName + " " + modelData.lastName
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
Item <beginfold id='1'>{</beginfold id='1'>
function say(text) <beginfold id='1'>{</beginfold id='1'>
console.log("You said " + text);
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
<beginfold id='2'>/*</beginfold id='2'>
* multi line comment
<endfold id='2'>*/</endfold id='2'>
// single line comment
import QtQuick 2.0
Rectangle <beginfold id='1'>{</beginfold id='1'>
property real myNumProp: 0.1e12;
property alias sub.color;
signal mySignal(int arg1, string arg2)
color: "lightsteelblue"
width: 320
height: width/2
Rectangle <beginfold id='1'>{</beginfold id='1'>
id: sub
width: 0x10
height: 007
objectName: 'single quote'
objectName2: a ? b : c;
<endfold id='1'>}</endfold id='1'>
Rectangle <beginfold id='1'>{</beginfold id='1'>
// comment
id: sub <beginfold id='2'>/*</beginfold id='2'> comment <endfold id='2'>*/</endfold id='2'>
<beginfold id='2'>/*</beginfold id='2'> comment <endfold id='2'>*/</endfold id='2'>width: 0x10
height <beginfold id='2'>/*</beginfold id='2'> comment <endfold id='2'>*/</endfold id='2'>: 007
objectName: <beginfold id='2'>/*</beginfold id='2'> comment <endfold id='2'>*/</endfold id='2'> 'single quote'
objectName2: a ? b : c <beginfold id='2'>/*</beginfold id='2'> comment <endfold id='2'>*/</endfold id='2'>;
<endfold id='1'>}</endfold id='1'>
<endfold id='1'>}</endfold id='1'>
|