Cannot Change UIFigure (App) Size Programmatically In 2022a

조회 수: 1 (최근 30일)
ILoveMATLAB
ILoveMATLAB 2022년 8월 5일
댓글: ILoveMATLAB 2022년 8월 12일
I decided to upgrade my app designer GUI from 2019b to 2022a, but my app does not function correctly in 2022a.
I have a class for my apps that contains different layouts for each app state.
In one function I have following lines of code.
function fooLayout(app, imSize)
%Code calculating new Figure Height was removed.
app.UIFigure.Position(4) =newFigureHeight;
app.UIFigure.Position(3) = 1000+30+340;
end
In 2019b the figure changes size in 2022a the uifigure/ app does not change size. What am I doing wrong?
Other notes;
  • Everything works correctly in 2019b.
  • If I put a drawnow after the code the figure size still does not change.
  • In 2022a the figure changes size if I put a break point before the code and step through each line.
  • In 2022a the figure changes size if I put a break point before the code and press continue.
  • In 2022a the figure changes size if put put a break point after the code. and press continue.

채택된 답변

Kevin Holly
Kevin Holly 2022년 8월 8일
편집: Kevin Holly 2022년 8월 8일
ILoveMATLAB,
I could not replicate your issue. I created an app in R2019b that change the size of UIFigure and then converted it in R2022a (see apps attached).
In your app, is newFigureHeight derived from imSize?
function fooLayout(app, imSize)
%Code calculating new Figure Height was removed.
app.UIFigure.Position(4) =newFigureHeight;
app.UIFigure.Position(3) = 1000+30+340;
end
  댓글 수: 4
Kevin Holly
Kevin Holly 2022년 8월 10일
편집: Kevin Holly 2022년 8월 10일
You can add the following:
app.UIFigure.Units = 'normalized';
app.UIFigure.Position(1) = (1-app.UIFigure.Position(3))/2;
app.UIFigure.Position(2) = (1-app.UIFigure.Position(4))/2;
app.UIFigure.Units = 'pixels';
See app attached.
Edit: The following command works for me too.
movegui(app.UIFigure,'center')
ILoveMATLAB
ILoveMATLAB 2022년 8월 12일
The expanded version of code worked in 2022a.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by