Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Can I use setappdata /getappdata to store data in a "panel" as the parent of uicontrol? Doesnt seem to work...

조회 수: 2 (최근 30일)
It seems setappdata will not store data in a panel - I had to store the data in the figure holding the panel. I have some uicontrols with a panel as their parent, and a figure is the parent of the panel. The getappdata didnt work in the uicallback:
getappdata(src.Parent,'DataName') % < this didnt work - points at panel
What did work in the uicontrol callback is:
getappdata(src.Parent.Parent,'DataName') % < this worked, points at figure
where
src.Parent.Parent breaks down as:
src = the uicontrol (a checkbox)
src.Parent = the panel containing the uicontrol
src.Parent.Parent = the figure containing the panel
What am I not understanding?
Thanks in advance.

답변 (1개)

Div Tiwari
Div Tiwari 2016년 8월 9일
Could you clarify what you mean by it not working? Was there an error message or was the data simply not stored? The 'setappdata' function supports 'uipanel' objects and it works just fine for me.
Please also try executing the example code in the 'uipanel' documentation page ( http://www.mathworks.com/help/matlab/ref/uipanel.html ) and using 'setappdata' with the panel. For example, for the first example, try:
>> setappdata(hp, 'DataName', 10);
>> getappdata(hp, 'DataName')
ans =
10

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by