简体   繁体   English

使用代码退出应用程序设计器 GUI - Matlab

[英]Quit an App designer GUI using a code - Matlab

How can I quit an App designer GUI using a button?如何使用按钮退出 App Designer GUI?

I tried this and it does not work:我试过了,但它不起作用:

function QuitButtonPushed(app, event)
          fig = uifigure;
          selection = uiconfirm(fig,'Close software?','Quit', 'Icon','warning');  
          switch selection
          case 'Yes'
          app.delete;
          case 'No'
         return 
        end

The switch case should be with 'OK' and 'Cancel' and not 'Yes' , 'No' .开关盒应带有'OK''Cancel'而不是'Yes''No'

It is also recommended to pass app.UIFigure instead of using fig = uifigure;也建议传递app.UIFigure而不是使用fig = uifigure; :

selection = uiconfirm(app.UIFigure,'Close software?','Quit', 'Icon','warning');

switch selection
    case 'OK'
        app.delete();
    case 'Cancel'
        return
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM