我正在研究matlab gui。我必须在点击当前gui的按钮时再调用另一个gui。但我必须传递一些值,如图像和文本字符串,从当前的gui到新的gui。我怎样才能做到这一点。我只是打开新的gui而不传递任何信息。
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
warning off;
choice = questdlg('Would you really want to goto next window ?', ...
'RESET Dialog', ...
'YES','NO','');
switch choice
case 'YES'
clc;clear all;close all;subpart;
case 'NO'
end
答案 0 :(得分:0)
让我们假设您要通过存储在句柄中的名为myData的结构传递所需的所有数据。然后,您只需简单地致电
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
warning off;
choice = questdlg('Would you really want to goto next window ?', ...
'RESET Dialog', ...
'YES','NO','');
switch choice
case 'YES'
mySecondGUI(handles.myData);
delete(hObject);
case 'NO'
end
这样,您的第二个GUI就会收到该信息。您要做的第二件事是在第二个gui中修改您的Opening函数:
mySecondGUID_OpeningFcn(hObject, eventdata, handles, varargin)
handles.theDataFromFirstGUI = varargin{1};
% ... Any initialisationstuff
guidata(hObject,handles);
如果您遇到旧gui无法正确关闭的问题,建议您阅读有关uiwait和uiresume的文章:https://www.mathworks.com/help/matlab/ref/uiwait.html
我希望这会有所帮助,帕勃罗欢呼