查看完整版本: [-- QML Treeview 加载警告。 --]

QTCN开发网 -> Qt QML开发 -> QML Treeview 加载警告。 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

angrycat 2020-04-11 21:21

QML Treeview 加载警告。

QML  在使用 Treeview 时用C++继承自QAbstractItemModel的数据模型,在加载时出现一大堆警告:
"Could not convert argument 2 at"
"expression for index@file:///D:/Qt/Qt5.12.3/5.12.3/mingw73_32/qml/QtQuick/Controls/Private/TreeViewItemDelegateLoader.qml:84"
"expression for onCompleted@file:///D:/Qt/Qt5.12.3/5.12.3/mingw73_32/qml/QtQuick/Controls/Private/BasicTableView.qml:546"
"Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
"This will throw a JavaScript TypeError in future releases of Qt!"

因为    虚函数 QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const;
最后一个默认参数是QModelIndex()而不是null,所以我把TreeViewItemDelegateLoader.qml的这一行null注释掉了,但还是会警告。
        readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1)//,null

请问有什么可以彻底解决的办法?


查看完整版本: [-- QML Treeview 加载警告。 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled