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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by