graphics displaying problem in gui after using copyobj

조회 수: 4 (최근 30일)
hui wang
hui wang 2022년 12월 16일
댓글: hui wang 2025년 4월 22일
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일
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
  댓글 수: 1
hui wang
hui wang 2025년 4월 22일
Ok, that makes sense, seems reasonable. I will find another way to get the work done. thanks for your time and suggestion

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by