Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Div Tiwari
Div Tiwari il 9 Ago 2016
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

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by