• 1925阅读
  • 0回复

[提问]QML Treeview 加载警告。 [复制链接]

上一主题 下一主题
离线angrycat
 

只看楼主 倒序阅读 楼主  发表于: 2020-04-11
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

请问有什么可以彻底解决的办法?
快速回复
限100 字节
 
上一个 下一个