Info
此问题已关闭。 请重新打开它进行编辑或回答。
Can I use setappdata /getappdata to store data in a "panel" as the parent of uicontrol? Doesnt seem to work...
1 次查看(过去 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.
0 个评论
回答(1 个)
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
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!