SHARE
TWEET

Untitled

a guest Apr 28th, 2016 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.4
  2. import QtQuick.Controls 1.2
  3.  
  4. ApplicationWindow {
  5.     id: theWindow
  6.     visible: true
  7.     width: 640
  8.     height: 480
  9.     title: qsTr("Hello World")
  10.  
  11.  
  12.  
  13.     Text {
  14.         text: qsTr("Click here to initiate incubation")
  15.         anchors.centerIn: parent
  16.     }
  17.  
  18.     MouseArea {
  19.         anchors.fill: parent
  20.  
  21.         // ----------------------------- EXAMPLE
  22.         property var component: null
  23.         Component.onCompleted: component = Qt.createComponent("IncubateMe.qml")
  24.  
  25.         onClicked: {
  26.             print(" ---- Next portion ---- ")
  27.             for (var i = 0; i < 10; i++) {
  28.                 createOne()
  29.             }
  30.         }
  31.  
  32.         property int idCounter: 0
  33.         property int incubatedCount: 0
  34.         onIncubatedCountChanged: print("onIncubatedCountChanged", incubatedCount)
  35.  
  36.         function createOne() {
  37.             ++incubatedCount
  38.             var incubator = component.incubateObject(theWindow, { x: 10, y: 60, someId: ++idCounter });
  39.             if (incubator.status != Component.Ready) {
  40.                 incubator.onStatusChanged = function(status) {
  41.                     --incubatedCount
  42.                     if (status == Component.Ready) {
  43.                         print ("Object", incubator.object, incubator.object.someId, "is now ready!");
  44.                     }
  45.                 }
  46.             } else {
  47.                 print ("Object", incubator.object, incubator.object.someId, "is ready immediately!");
  48.             }
  49.         }
  50.  
  51.         // -----------------------------
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top