diff --git a/src/TaoQuick/Qml/Basic/CusCallLater.qml b/src/TaoQuick/Qml/Basic/CusCallLater.qml new file mode 100644 index 0000000..f7c6ddb --- /dev/null +++ b/src/TaoQuick/Qml/Basic/CusCallLater.qml @@ -0,0 +1,28 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +Item { + Component { + id: timerComp + Timer { + id: timer + repeat: false + property var _cb: function() {} + onTriggered: { + console.log("trigger") + _cb() + destroy(parent) + } + function setTimeout(callback, delayTime) { + _cb = callback; + interval = delayTime; + console.log("setTimeout", interval) + start(); + } + } + } + function callLate(callback, delayTime) { + var timerObj = timerComp.createObject() + timerObj.setTimeout(callback, delayTime) + } + +} diff --git a/src/TaoQuick/TaoQuick.qrc b/src/TaoQuick/TaoQuick.qrc index b7c8047..9bca328 100644 --- a/src/TaoQuick/TaoQuick.qrc +++ b/src/TaoQuick/TaoQuick.qrc @@ -4,6 +4,7 @@ Qml/CusConfig.qml Qml/Basic/BasicText.qml Qml/Basic/BasicTooltip.qml + Qml/Basic/CusCallLater.qml Qml/Basic/MoveArea.qml Qml/Basic/RoundRectangle.qml Qml/Basic/RoundRectangleShape.qml diff --git a/src/TaoQuick/qmldir b/src/TaoQuick/qmldir index cb16bc8..ccf09b9 100644 --- a/src/TaoQuick/qmldir +++ b/src/TaoQuick/qmldir @@ -1,6 +1,7 @@ module TaoQuick BasicText 1.0 Qml/Basic/BasicText.qml BasicTooltip 1.0 Qml/Basic/BasicTooltip.qml +CusCallLater 1.0 Qml/Basic/CusCallLater.qml MoveArea 1.0 Qml/Basic/MoveArea.qml RoundRectangle 1.0 Qml/Basic/RoundRectangle.qml RoundRectangleShape 1.0 Qml/Basic/RoundRectangleShape.qml