Qt4.8 assigning a JavaScript function to a property
-
I thought this was interesting. While you can't assign a function apparently, you can declare a function when use a component. So below, thing1 will use the
somefunc
declared in the Thing component. thing2 will use the customsomefunc
declared when we declare thing2. Still can't find a better way.main.qml:
@
import QtQuick 1.0Item
{
Thing
{
id: thing1
}Thing { id: thing2; function somefunc() { console.log("custom func") } }
}
@Thing.qml:
@
import QtQuick 1.0Item
{
function somefunc()
{
console.log("default")
}Component.onCompleted: { somefunc(); }
}
@