Hello everyone! So i am kind of new to MATLAB. I created a UI with tabs, however when i maximise the UI figure, the tabs do not resize along with it. How can i manage this? Thank you in advance.

1 回表示 (過去 30 日間)
ALEXANDROS
ALEXANDROS 2024 年 4 月 14 日
編集済み: Voss 2024 年 5 月 19 日
clear all
clc
%Creating Tabs
fig = uifigure("Name","BISC");
set(fig, 'Units', 'normalized', 'Position', [0.1, 0.1, 0.8, 0.8]);
tg = uitabgroup(fig,'Units','normalized',"Position",[0,0,1,1]);
t1 = uitab(tg,"Title","Data");
tg1 = uitabgroup(t1,'Units','normalized',"Position",[0,0,1,1]);
t3 = uitab(tg1, 'Title', 'Tab 3');
t4 = uitab(tg1, 'Title', 'Tab 4');
t2 = uitab(tg,"Title","Plots");
tg2 = uitabgroup(t2,'Units','normalized',"Position",[0,0,1,1]);
t5 = uitab(tg2, 'Title', 'Tab 5');
t6 = uitab(tg2, 'Title', 'Tab 6');
t1.Scrollable = "on";
t2.Scrollable = "on";

回答 (1 件)

Voss
Voss 2024 年 4 月 15 日
It seems like having AutoResizeChildren set to 'on' (which is the default) conflicts with positioning children whose Units are 'normalized'. To work around that and have the normalized positions respected, set AutoResizeChildren to 'off' for the uifigure and for the uitabs that contain uitabgroups.
%Creating Tabs
fig = uifigure("Name","BISC",'Units','normalized','Position',[0.1, 0.1, 0.8, 0.8],'AutoResizeChildren','off');
tg = uitabgroup(fig,'Units','normalized',"Position",[0,0,1,1]);
t1 = uitab(tg,"Title","Data",'AutoResizeChildren','off');
tg1 = uitabgroup(t1,'Units','normalized',"Position",[0,0,1,1]);
t3 = uitab(tg1, 'Title', 'Tab 3');
t4 = uitab(tg1, 'Title', 'Tab 4');
t2 = uitab(tg,"Title","Plots",'AutoResizeChildren','off');
tg2 = uitabgroup(t2,'Units','normalized',"Position",[0,0,1,1]);
t5 = uitab(tg2, 'Title', 'Tab 5');
t6 = uitab(tg2, 'Title', 'Tab 6');
  4 件のコメント
ALEXANDROS
ALEXANDROS 2024 年 5 月 19 日
R2023b. What if i create a function? I haven't tried it yet, as i am busy with other university responisbilities and exams, but it is a thought i had.
Voss
Voss 2024 年 5 月 19 日
編集済み: Voss 2024 年 5 月 19 日
I have just tested the solution in R2023b and confirmed that it works.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by