set and get on two gui

1 visualización (últimos 30 días)
pink
pink el 12 de Jun. de 2011
I made two gui, gui A (input) and gui B (table), when I enter data into gui B, the data is lost and only appear later in case of error, so I need your advice
??? Error using ==> setappdata Invalid object handle
Error in ==> gui_mainfcn at 242 setappdata(gui_hFigure,'GUIOnScreen', 1);
Error in ==> main at 40 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
Error in ==> inputmaterial>okbutton_Callback at 77 mainGUIhandle = main;
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> inputmaterial at 16 gui_mainfcn(gui_State, varargin{:});
my code
function okbutton_Callback(hObject, eventdata, handles)
% hObject handle to okbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mainGUIhandle = main;
mainGUIdata = guidata(mainGUIhandle);
inputmaterial=get(handles.applybutton,'UserData')
set(mainGUIdata.table1,'data',inputmaterial)
guidata(main, mainGUIdata);
close

Respuesta aceptada

Paulo Silva
Paulo Silva el 12 de Jun. de 2011
The error is in the line:
mainGUIhandle = main;
In that context MATLAB doesn't know what the variable main is because it's not defined, maybe you can use:
mainGUIhandle = gcf;
or
mainGUIhandle = handles.figure1;

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by