2017-10-17 3 views
0

JUCE의 ValueTree에서 읽음으로써 탭이있는 창을 만들려고합니다.JUCE - Member Function Not Viable : 'this'인수의 유형이 const입니다.

아래 코드를 사용하여 해당 탭의 루트 항목을 트리의 하위 (전체 코드는 here)로 설정합니다. 나는 나무가 getValueTree()에 의해 반환 또는 함수 자체가 아닌 정적으로 객체를 사용하고

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

: 그러나, 나는 오류가 발생합니다.

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

@Jefferson, 확실한 것, 행운 : :) –