How can I get a uitabgroup to resize properly
8 次查看(过去 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!