我正在尝试通过从JUCE中的ValueTree读取来创建选项卡式窗口。
我正在使用以下代码将相应选项卡的根项设置为树的子级(此处提供完整代码)。但是,我得到了错误:
“成员函数'getValueTree'不可行:'此'自变量的类型为'const GlobalValueTree',但函数未标记为const”。
我使用的是对象,因为返回的树getValueTree()
或函数本身是非静态的。
AccelerometerPage (const DataSelectorWindow& w)
{
tree.setRootItem (rootItem = new const OscValueTreeItem
(w.valueTree.getValueTree()->getChildWithName ("AccData")));
}
有人可以为我指出正确的方向,为什么这是不正确的,以及如何解决它?
我收到错误消息“成员函数'getValueTree'不可行:'this'参数的类型为'const GlobalValueTree',但函数未标记为const”
这是因为w
isconst
但是该方法getValueTree
只能在非constDataSelectorWindow
对象上工作。
如果DataSelectorWindow对象是您编写的,并且您认为getValueTree()
应允许在const
对象上调用该对象,则将其原型更改为:
<return-value> getValueTree(<params>) const {
...
}
如果DataSelectorWindow对象是由其他人编写的,则您的AccelerometerPage
计算机应该收到一个非const DataSelectorWindow&
,如下所示:
AccelerometerPage (DataSelectorWindow& w) {
...
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句