2017-10-17 12 views
0

JUCEのValueTreeから読み込んでタブ付きウィンドウを作成しようとしています。JUCE - 実行不可能なメンバー関数: 'this'引数の型はconstです

以下のコードを使用して、対応するタブのルート項目をツリーの子に設定します(フルコードはhere)。しかし、私はエラーを取得:

"Member function 'getValueTree' not viable: 'this' argument has type 'const GlobalValueTree', but function is not marked const".

私はgetValueTree()によって返された木や関数自体としてオブジェクトを使用しています非静的です。

AccelerometerPage (const DataSelectorWindow& w) 
{ 
    tree.setRootItem (rootItem = new const OscValueTreeItem 
    (w.valueTree.getValueTree()->getChildWithName ("AccData"))); 
} 

これが間違っている理由と、それを修正する方法について誰かが正しい方向に向いていますか?

答えて

2

I get the error "Member function 'getValueTree' not viable: 'this' argument has type 'const GlobalValueTree', but function is not marked const"

wconstですが、方法getValueTreeのみ非const DataSelectorWindowオブジェクト上で動作することができるからです。

DataSelectorWindowオブジェクトはあなたによって書かれた、とあなたはgetValueTree()は、constオブジェクトで呼び出すことが可能にそのプロトタイプを変更する必要があると考えていた場合:DataSelectorWindowオブジェクトが他の人によって書かれていた場合

<return-value> getValueTree(<params>) const { 
    ... 
} 

AccelerometerPage (DataSelectorWindow& w) { 
    ... 
} 
+0

ありがとう:あなたの AccelerometerPage c'torはこのように、非const DataSelectorWindow&を受けるべきです!私はまだ大規模なプロジェクトで作業することについて学んでおり、まだまだ時々起こる問題があります。 – Jefferson

+0

@ジェファーソン、確かなこと、幸運:) –

関連する問題