Clear Filters
Clear Filters

How can I get a uitabgroup to resize properly

18 views (last 30 days)
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';
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);
% The scrollbar does not appear
tab1.Scrollable = 'on';
fig.Visible = 'on';
  1. When resizing the uifigure the uitab's width matches the new dimensions but the uitab's height remains the same.
  2. The uitab's 'Scrollable' property does not work. No scrollbar appears and using the mousewheel has no effect.
  3. Turning fig.Visible to off does not work. The uifigure is visible while all elements are placed.
  4. After maximizing the uifigure window the axes are extremely pixelated.

Answers (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi on 23 Feb 2021
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!


Find more on Develop uifigure-Based Apps in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!