How can I get a uitabgroup to resize properly
조회 수: 10 (최근 30일)
이전 댓글 표시
The goal is to get a uitab that contains a 12 by 3 uigridlayout. In each row of the uigridlayout should be a panel and to axes.
The uitab should be scrollable and its dimensions should match the dimensions of the uifigure if the uifigure gets resized.
data = 0:1:10;
fig = uifigure;
% Turning fig.Visible to off does not seem to work. The uifigure is visible
% while all elements are placed.
fig.Visible = 'off';
% Create a tabgroup with the dimensions of the uifigure
tab_group = uitabgroup(fig, 'Position', [0 0 fig.Position(3) fig.Position(4)]);
tab1 = uitab(tab_group, 'Title', 'Tab 1');
grid_layout = uigridlayout(tab1, [12 3]);
c=cell(1, 12);
for i = 1:12
c{i} = 'fit';
end
grid_layout.RowHeight = c;
grid_layout.ColumnWidth = {'1x', '1x', '1x'};
for i =1:12
panel = uipanel(grid_layout, 'Title', ['Panel ', num2str(i)]);
panel.Layout.Row = i;
panel.Layout.Column = 1;
for j = 2:3
ax = uiaxes(grid_layout);
ax.Layout.Row = i;
ax.Layout.Column = j;
plot(ax, data, data);
end
end
% The scrollbar does not appear
tab1.Scrollable = 'on';
fig.Visible = 'on';
Problems:
- When resizing the uifigure the uitab's width matches the new dimensions but the uitab's height remains the same.
- The uitab's 'Scrollable' property does not work. No scrollbar appears and using the mousewheel has no effect.
- Turning fig.Visible to off does not work. The uifigure is visible while all elements are placed.
- After maximizing the uifigure window the axes are extremely pixelated.
댓글 수: 0
답변 (1개)
Sahithi Kanumarlapudi
2021년 2월 23일
Hi,
You have to also set the scrollable property of 'uigridlayout' top 'on' to view the scroll bar as you are creating grid layout on the tab.
grid_layout.Scrollable = 'on';
And I did not face any issue with the 'Visible' property of figure, it is working as expected and also the forth problem that you have mentioned.
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!