GUI: error using set

조회 수: 10 (최근 30일)
Ignacio Lobato
Ignacio Lobato 2015년 4월 30일
답변: Jan 2015년 4월 30일
Hi!
I am getting the following error everytime I use the set function in GUI to check/uncheck checkboxes:
Error using set
There is no Value property on the Figure class.
Error in GUI>Selectall_Callback (line 271)
set(handles.check0, 'Value', 1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI('Selectall_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
My code is the following:
The opening function (error appears also with the opening function empty, but the error appears in the function selectall, here no error is given)
% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for GUI
handles.output = hObject;
set(handles.check0, 'Value', 0);
set(handles.check5, 'Value', 0);
set(handles.check10, 'Value', 0);
set(handles.check15, 'Value', 0);
set(handles.check20, 'Value', 0);
set(handles.check25, 'Value', 0);
set(handles.check30, 'Value', 0);
% Update handles structure
guidata(hObject, handles);
And the button to check all boxes (error appears when I press this button)
function Selectall_Callback(hObject, eventdata, handles)
set(handles.check0, 'Value', 1);
set(handles.check5, 'Value', 1);
set(handles.check10, 'Value', 1);
set(handles.check15, 'Value', 1);
set(handles.check20, 'Value', 1);
set(handles.check25, 'Value', 1);
set(handles.check30, 'Value', 1);
Thanks for your help!!
  댓글 수: 1
Adam
Adam 2015년 4월 30일
편집: Adam 2015년 4월 30일
Have you double-checked the tags of your checkboxes in GUIDE?
For some reason that isn't immediately obvious to me the code seems to think that handles.check0 is a figure object rather than a checkbox.
I have sometimes got tangled up in the past with GUIDE-created GUIs but usually if I do something like incorrectly editing a previously automated callback or renaming the GUI file.
Editing the GUI while still in a debug session on the same GUI also causes a mess from which I usually have to cancel all my GUI changes since the last save.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2015년 4월 30일
Check the code, if the variable handles.check0 is set to the figure handle anywhere. If the OpeningFcn runs successfully, this variable must be correct, but later on the contents must have been changed.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by