2

I am trying to use AWS SDK (https://sdk.amazonaws.com/js/aws-sdk-2.0.30.js) in my Qt-Creator Project with the purpose of uploading an image to my S3 bucket.

I have copy-pasted the JavaScript above to a file named awsSdk.js and did the following in my main.qml file:

// main.qml
import QtQuick 2.3
import QtQuick.Window 2.2

import "jsTest.js" as JsTest
import "awsSdk.js" as AWSSdk

Window {
visible: true
width: 360
height: 360

Rectangle {
    width: 360
    height: 360
    color: "white"
    Text {
        id: txt
        anchors.centerIn: parent

        text: "Counter"
        color: "Blue"

    }
    MouseArea {
        x: 0
        y: 0
        anchors.fill: parent
        onClicked: {
            if (JsTest.x>=20) {
                console.log("Have a nice day :)");
                Qt.quit();
            }
            else
                txt.text = JsTest.jsTest();
        }
    }
}
}

I can import the jsTest.js file perfectly. But when I try to do the same for awsSdk.js I get the following error:

QQmlApplicationEngine failed to load component
qrc:/main.qml:8 Script qrc:/awsSdk.js unavailable
qrc:/awsSdk.js:6023 Expected token `identifier'

Source Code for jsTest.js:

// jsTest.js
var x=0;
function jsTest()
{
    x++;
    return "Counter : "+x+"";
}

Have I missed something? Do you have another suggestion for I to upload a file to AWS S3 from a Qt Project using only QML/Javascript?

4

1 回答 1

0

由问题编辑回答 - 转换为社区 wiki。

OP写道:

现在已经解决了。由于某种原因, inqml.qrc缺少指向文件的指针。手动添加它,现在它正在工作。

qml.qrc 文件内容:

<RCC>
    <qresource prefix="/">
    <file>main.qml</file>
    <file>jsTest.js</file>
    <file>jQuery.js</file>
    <file>aws-sdk-2.0.30.js</file>
    </qresource>
</RCC>
于 2015-04-26T18:16:35.627 回答