首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

#qml

qml使用c库?

如何在QML中执行“is_a”、“type of”或instanceof?

下面是使用toString()的另一种方法(它可能无法移植到未来版本的QML): function qmltypeof(obj, className) { // QtObject, string -> bool // className plus "(" is the class instance without modification // className plus "_QML" is the class instance with user-defined properties var str = obj.toString(); return str.indexOf(className + "(") == 0 || str.indexOf(className + "_QML") == 0; } ... for (var i = 0; i < controls.children.length; ++i) { if (qmltypeof(controls.children[i].height, "QDeclarativeRectangle")) { // do stuff } }... 展开详请
领券