Sharing values between 2 app designer apps

조회 수: 10 (최근 30일)
MASSIMO D'ANNA
MASSIMO D'ANNA 2023년 11월 13일
댓글: Jon 2023년 11월 15일
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