Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.4
- import QtQuick.Controls 1.2
- ApplicationWindow {
- id: theWindow
- visible: true
- width: 640
- height: 480
- title: qsTr("Hello World")
- Text {
- text: qsTr("Click here to initiate incubation")
- anchors.centerIn: parent
- }
- MouseArea {
- anchors.fill: parent
- // ----------------------------- EXAMPLE
- property var component: null
- Component.onCompleted: component = Qt.createComponent("IncubateMe.qml")
- onClicked: {
- print(" ---- Next portion ---- ")
- for (var i = 0; i < 10; i++) {
- createOne()
- }
- }
- property int idCounter: 0
- property int incubatedCount: 0
- onIncubatedCountChanged: print("onIncubatedCountChanged", incubatedCount)
- function createOne() {
- ++incubatedCount
- var incubator = component.incubateObject(theWindow, { x: 10, y: 60, someId: ++idCounter });
- if (incubator.status != Component.Ready) {
- incubator.onStatusChanged = function(status) {
- --incubatedCount
- if (status == Component.Ready) {
- print ("Object", incubator.object, incubator.object.someId, "is now ready!");
- }
- }
- } else {
- print ("Object", incubator.object, incubator.object.someId, "is ready immediately!");
- }
- }
- // -----------------------------
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement