GUI: error using set

2 次查看(过去 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 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by