I've written this Basic Qml file which imports QtTest but is not a test.
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtTest 1.1
ApplicationWindow {
id: window
width: 400
height: 250
visible: true
menuBar: MenuBar {
Menu{
title: "alpha"
MenuItem{ text: "print after 1 sec"; onTriggered:{printAfterDelay(1000)}}
}
}
Rectangle{
anchors.fill: parent
color: "red"
}
function printAfterDelay(delay){
wait(delay);
console.log("print")
}
}
Once I run it, it throws the error: ReferenceError: wait is not defined
.
Does this function only work while running actual test cases or am I doing something wrong? And if it only runs with test cases, are there other alternatives (not including timer)?
PS: I'm trying to avoid timer because when the code becomes more complex and relies on multiple timers it sacrifices a lot of readability.