How can I close an App Designer App programmatically?

108 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2022 年 1 月 10 日
編集済み: MathWorks Support Team 2023 年 7 月 3 日
Given an App Designer App, how can I close the App programmatically in MATLAB once I have launched it?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 7 月 3 日
編集済み: MathWorks Support Team 2023 年 7 月 3 日
There are multiple ways to close an AppDesigner app after launching it, in the following you can find the two "most common" variants:
Ensure that you request a handle to the app when starting it:
myHandle = myApp;
You can then use this handle to later close the app:
delete(myHandle)
The more common workflow of closing the app from inside the app can be accomplished by calling the 'delete' command from a callback in the app, e. g. in a button pushed callback, it works the same as above:
In the following code 'app' represents the handle to the app.
% Button pushed function: ExitButton
function ExitButtonPushed(app, event)
% Shut down the entire app
delete(app)
end
You can find more information about callbacks here:

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 1 月 10 日
If you want to close it programmatically from an "Exit" button you have placed on the window, you can call the delete method of app from within the callback function for the Exit button:
% Button pushed function: ExitButton
function ExitButtonPushed(app, event)
app.delete % Shut down the entire app
end

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by