graphics displaying problem in gui after using copyobj

2 visualizzazioni (ultimi 30 giorni)
hui wang
hui wang il 16 Dic 2022
Risposto: Divyam il 7 Nov 2024 alle 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)

Risposte (1)

Divyam
Divyam il 7 Nov 2024 alle 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

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by