【问题标题】:Matlab checkbox guiMatlab复选框gui
【发布时间】:2012-04-19 10:37:06
【问题描述】:

我在 GUI 上有一个复选框,可以在实时视频源上绘制一个矩形,但是,当我取消选中它时,我需要该矩形消失或被删除。 有人知道怎么做吗?

这是我的代码,我试过把东西放在 else 里面,但是没有用。

function Box(hObject,eventdata)

if (((get(hObject,'Value') == get(hObject,'Max'))))
 % Checkbox is checked-take appropriate action
 hold on;
rectangle('Position',[50,50,100,100],'EdgeColor','r')
else
end

【问题讨论】:

    标签: matlab user-interface checkbox


    【解决方案1】:

    您需要保存函数矩形创建的句柄。然后将此句柄添加到 GUI 的大句柄中,以便在再次调用回调时能够访问它。

    所以像这样修改你的函数

    function Box(hObject,eventdata,handles)
    
    if (((get(hObject,'Value') == get(hObject,'Max'))))
     % Checkbox is checked-take appropriate action
     hold on;
    handles.rectangleSave=rectangle('Position',[50,50,100,100],'EdgeColor','r');
    guidata(handles.output,handles);
    else
    delete(handles.rectangleSave);
    end
    

    如果您从未使用过手柄,请看这里: http://www.matlabtips.com/on-handles-and-the-door-they-open/

    handles.output 通常存储大界面窗口的句柄,如下所述: http://www.matlabtips.com/guide-me-in-the-guide/

    【讨论】:

      猜你喜欢
      • 2015-01-18
      • 2014-05-09
      • 2010-10-21
      • 2014-10-20
      • 2016-10-01
      • 1970-01-01
      • 2017-04-03
      • 2015-05-20
      • 2012-12-05
      相关资源
      最近更新 更多