Skip to content

Minimal Installation (with just promise.js, PromiseTimer.qml) #12

Description

@hstig

Rplaced the code in Minimal Installation...

                var promise = new Q.Promise(function(resolve, reject) {

                    // ...

                });            

with...

                let promise = Q.promise(function(resolve, reject) {

                    resolve('my promise');

                }).then(function(value){

                    console.log(value);

                });            

...and added paths of both files into qml.qrc!

<RCC>
    <qresource prefix="/">
        <file>main.qml</file>
        <file>QuickPromise/promise.js</file>
        <file>QuickPromise/PromiseTimer.qml</file>
    </qresource>
</RCC>

After this Minimal Installation works with

import QtQuick 2.12

import Qt.labs.platform 1.1

import QtQuick.Controls 2.12

import "./QuickPromise/promise.js" as Q



ApplicationWindow {



    visible: true



    Rectangle{

        visible: true

        width: parent.width

        height: parent.width

                

        Button{

            width: parent.width

            height: parent.width

            

            text: "Test"

            onClicked: {

                console.log("----------- new Q.Promise(function(resolve, reject) ---------------------")

                var promise = Q.promise(function(resolve, reject) {

                    resolve("my promise");

                }).then(function(value){

                    console.log(value);

                });            



            }

        }

    }

}

When Button 'Test' is pressed, it results in:

qml: ----------- new Q.Promise(function(resolve, reject) ---------------------

qml: my promise

Activity

  1. changed the title [-]Minimal Install (with just promise.js, PromiseTimer.qml)[/-] [+]Minimal Installation (with just promise.js, PromiseTimer.qml)[/+] on May 11, 2022
  2. hstig commented on May 11, 2022

    @hstig
    Author

    @benlau Please be more clear in Minimal Installation . And replace every 'Q.Promise' with 'Q.promise'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions