How to call a static method without an instance?

How does one call a static class method for Dz* classes?

It works as expected on ECMAScript classes:

Array.isArray([])
Date.now()
String.fromCharCode(65)

But fails for all the DAZ classes:

DzDir.cleanPath("/Path")
DzUri.fromLocalFilename("/Path")
DzVersion.fromString("1.0")

 

Comments

  • jag11jag11 Posts: 885

    Just create an instance with dummy values.

    var dir = new DzDir("");
    print(JSON.stringify(dir.home()));
    print(JSON.stringify(dir.cleanPath("/Path")));
    

     

  • "static" functions on Dz* objects are not statically callable via script, rather they operate on an object of the type in a "static" context... meaning they operate generically, without concern for the member data associated with any discrete instance.

  • Richard Haseltine said:

    "static" functions on Dz* objects are not statically callable via script, rather they operate on an object of the type in a "static" NNocontext... meaning they operate generically, without concern for the member data associated with any discrete instance.

    They're not correctly described as 'static' then, or not as the rest of the universe outside Daz-world defines them!  Very confusing, and unnecessarily so - why call them static when they don't behave in the way that would suggest?

  • I would expect this usage is at least general across Qt.

Sign In or Register to comment.