graphics displaying problem in gui after using copyobj

2 ビュー (過去 30 日間)
hui wang
hui wang 2022 年 12 月 16 日
回答済み: Divyam 2024 年 11 月 7 日 4:43
I established a set of Gridlayout objs, and put a Label, a NumericEditField and a Slider obj into each of them, which displayed very well in GUI. After that, I want to established another set of Gridlayout objs in the same GUI,which contained some Gridlayout objs used before. The copyobj funtion did the great job, it copied everything Gridlayout objs used before. when I run the GUI, the Value of NumericEditField and Slider obj displayed was not same with I set. So how can I keep them remain same?
Objs to copy Objs copied(new parent)

回答 (1 件)

Divyam
Divyam 2024 年 11 月 7 日 4:43
Assuming that you're experiencing issues with the "copyObj" function not accurately copying data from the original GUI, I have faced this issue and this is a recognized problem with the "copyObj" function.
As a workaround, you can manually copy the original values from the GUI components. After using the "copyObj" function, you can then update the values of the objects that weren't copied correctly by using the values from the original GUI objects.
% Pseudocode
ef = uieditfield(); % Create your numeric edit field
editfieldValue = ef.Value;
sld = uislider(); % Create your slider
sliderValue = sld.Value;
% code for copied objs
copiedEF.Value = editfieldValue;
copiedSlider.Value = sliderValue;
Note: Before using "copyObj" function for a GUI object, you can go through this documentation section to have a better idea of properties that might need to be set again after copying the original object: https://www.mathworks.com/help/matlab/ref/copyobj.html?s_tid=doc_ta#:~:text=expand%20all-,What%20Is%20Not%20Copied,-Tips

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by