Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Joshua Gordis
Joshua Gordis 2016 年 7 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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