同じ構成を持つ Tab グループの選択を同期させることはできますか?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 13 Sep. 2022
Bearbeitet: MathWorks Support Team
am 12 Aug. 2025
Figure 上に同じ Tab 名を持つ UITabgroup を配置しています。
片方のタブを切り替えた際、もう一方のタブも同期してタブを切り替える方法を教えてください。
Akzeptierte Antwort
MathWorks Support Team
am 12 Aug. 2025
Bearbeitet: MathWorks Support Team
am 12 Aug. 2025
uitabgroup のタブ選択を同期させる場合、uitabgroup の SelectionChangedFcn コールバックを使用します。それぞれの uitabgroup における選択中のタブを示す SelectedTab プロパティを更新します。
各プロパティの詳細については以下のヘルプドキュメントをご覧ください。
・ uitabgroup: SelectionChangedFcn コールバックhttps://jp.mathworks.com/help/matlab/ref/uitabgroup.html#mw_812524ee-1717-48b0-850a-6f1c1920751f
・uitabgroup: SelectedTab プロパティhttps://jp.mathworks.com/help/matlab/ref/matlab.ui.container.tabgroup.html?searchHighlight=tab%20selectedtab&s_tid=srchtitle_tab%20selectedtab_2#d123e1594887
以下に簡単な例を示します。
この例では、それぞれの uitabgroup に紐づくタブの Title は一致していることを想定し、同じ Title である uitab オブジェクトを findobj 関数を使って検出しています。
clear, close all
f = figure(1);
Gname = {'Group A', 'Group B'}; % タブ名
tabgp1 = uitabgroup(f,'Position',[.05 .05 .3 .8],'SelectionChangedFcn',@selectfun);
tab1_a = uitab(tabgp1,'Title',Gname{1});
tab1_b = uitab(tabgp1,'Title',Gname{2});
tabgp2 = uitabgroup(f,'Position',[.4 .05 .3 .8],'SelectionChangedFcn',@selectfun);
tab2_a = uitab(tabgp2,'Title',Gname{1});
tab2_b = uitab(tabgp2,'Title',Gname{2});
function selectfun(obj,evt)
% SelectionChangedFcn
h = findobj(obj.Parent,'Title',evt.NewValue.Title); % 同じTitleを持つ uitab の検出
for n = 1:length(h)
h(n).Parent.SelectedTab = h(n); % uitab を選択
end
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu GUIDE アプリの移行 finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!