How can I get a uitabgroup to resize properly

19 visualizaciones (últimos 30 días)
Victor Haase Coelho
Victor Haase Coelho el 18 de Dic. de 2020
Respondida: Sahithi Kanumarlapudi el 23 de Feb. de 2021
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:
  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.

Respuestas (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi el 23 de Feb. de 2021
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!

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by