Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************************
- Text.qml
- **********************************************************/
- import QtQuick 1.1
- Rectangle {
- width: parent.width
- height: parent.height
- color: "transparent"
- Text {
- font.family: "Gabriola"
- font.pointSize: 15
- color: "white"
- text: "This is static text"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- Qt.quit()
- }
- }
- }
- /*********************************************************
- MainView.qml
- **********************************************************/
- import QtQuick 1.1
- import "./Try_js.js" as GO
- Rectangle {
- id: mainView
- width: 240
- height: 320
- color:"black"
- Component.onCompleted: GO.createSpriteObjects("mainView","Text.qml","{}")
- }
- /*********************************************************
- Try_js.js
- **********************************************************/
- var component;
- var sprite;
- function createSpriteObjects(parent,thing,props) {
- console.log(parent+":"+thing+":"+props);
- component = Qt.createComponent(thing);
- console.log("created component!");
- if (component.status == Component.Ready) {
- console.log("Component is Ready: "+component);
- finishCreation(parent,props);
- }
- else
- component.statusChanged.connect(finishCreation(parent,props));
- // console.log("created component!");
- }
- function finishCreation(parent,props) {
- console.log(parent+":"+props);
- if (component.status == Component.Ready) {
- sprite = component.createObject(parent, props);
- if (sprite == null) {
- // Error Handling
- console.log("Error creating object");
- }
- }
- else if (component.status == Component.Error) {
- // Error Handling
- console.log("Error loading component:", component.errorString());
- }
- }
- /**************************************
- Compiled output
- ****************************************/
- Qml debugging is enabled. Only use this in a safe environment!
- mainView:Text.qml:{}
- created component!
- Component is Ready: QDeclarativeComponent(0xa361a0)
- mainView:{}
- <Unknown File>: QML Component: createObject: value is not an object
- Error creating object
- C:\QtSDK\Desktop\Qt\4.8.0\mingw\bin\qmlviewer.exe exited with code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement