Sharing values between 2 app designer apps

23 次查看(过去 30 天)
Hello guys, I'm trying to create 2 mlapp to pass data from one to another.
Basically I need to read value of a drop down menu which is present in App2 and then send this value (for example pressing a button) to an uitable in App1.
I have read many guides about this argument, even official one, but I don't understand how to write my code.
I hope someone could help me. Thanks

回答(1 个)

Jon
Jon 2023-11-13
编辑:Jon 2023-11-13
I have attached two MATLAB Apps that provide a highly simplified example of how to do what I think you are asking.
Please save these two files to your working directory.
To run the example type main on the command line.
This will open main.mlapp, and the startup function in main.mlapp will open helper.mlapp. (The second app may be right behind the other one so move the windows around to see both)
On the helper app, pick an animal name from the drop down, and then press the button to send the data to the main app.
Look at the startup function for main, you will see it calls helper, and passes a reference to itself to helper so that helper can send data back. A property, called mainApp is defined in help.mlapp to store this reference. When help.mlapp opens, it's start up function saves this reference to the property app.mainApp so that it can access it when it needs it.
The callback for the send push button then get the data from the dropdown assigning it to the local variable, selection, and then sends the data to the main app using app.mainApp.animalTable.Data = {selection}
  2 个评论
Jon
Jon 2023-11-13
By the way, app designer also supports having multiple tabs within the same app. Could you design your application to just use separate tabs instead of having multiple apps. If so that would be a lot simpler, and everything would be self contained in one app.
Jon
Jon 2023-11-15
Did this answer your question? Did you have any further questions. If this answered your question please accept the answer so that others with similar issues will know an answer is available

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by