Can I hide a tab in MATLAB App Designer?

조회 수: 97 (최근 30일)
Anna Zeng
Anna Zeng 2019년 10월 17일
댓글: Anna Zeng 2020년 6월 20일
Hello,
I created a GUI with multiple tabs in a TabGroup, and would like to use flags/buttons to control the visibility of tabs, so I have different tabs for different configs.
But I found that you can only hide the whole TabGroup, you cannot hide a tab inside because there is no 'Visible' option.
Is there a way to achieve this or I have to use other GUI such as Python? Thanks!
Anna

채택된 답변

Anna Zeng
Anna Zeng 2019년 10월 17일
I found a solution, after you export your .mlapp file into .m file, add your flag to 'function createComponents(app,flag)' at the section:
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
use flag to create if condition for the related conponents would be ok.
  댓글 수: 2
yumeng Jiang
yumeng Jiang 2019년 10월 30일
i cant find relevant code online,i dont know what code i should add to the .m file. i m new to this appdesigner ,i really need to solve this problem, please help me ,im greatly appreciated.
Anna Zeng
Anna Zeng 2019년 10월 30일
First you need to use Ctrl+F find the code I mentioned above, and the code inside createComponents function contains every component in your app.
Then find the tab you want to hide, and add if condition outside of the creation. e.g. you want to use flag to control the appearance of Main tab:
if flag == 1
% Create MainTab
app.MainTab = uitab(app.MasterTabGroup);
app.MainTab.Title = 'Main';
end

댓글을 달려면 로그인하십시오.

추가 답변 (5개)

yumeng Jiang
yumeng Jiang 2019년 10월 30일
hi do you know how to hide the title of tabgroup???
  댓글 수: 1
Anna Zeng
Anna Zeng 2019년 10월 30일
Hi, I believe my answer above is the solution, but please let me know if you have better idea. Thanks!

댓글을 달려면 로그인하십시오.


yumeng Jiang
yumeng Jiang 2019년 10월 30일
您好 不知道您能否看懂中文 我是想问一下 如何能够将上面的那一栏隐藏掉,我想实现在一个窗口内有多个界面可以进行切换。我最初想用多个panel分别设置visible但是失败了,因为会发生重叠后包含的父子关系,这个问题还没有解决。于是我想用这个Tabgroup来实现 我是不希望在我的界面中看到上面那一栏的, 不知道您有什么办法么???
1.jpg
  댓글 수: 1
Anna Zeng
Anna Zeng 2019년 10월 31일
您好,只要你移的位置够好是可以做到重叠没有父子关系的,如果用tabgroup的话当前tab还是会显示的你没法隐藏。

댓글을 달려면 로그인하십시오.


yumeng Jiang
yumeng Jiang 2019년 10월 30일
i want to hide the top line(title line) of tabgroup , could u tell more details about your solution?? can i contact with you on wechat or q if possible???thank you !!!!!
1.jpg
  댓글 수: 1
Anna Zeng
Anna Zeng 2019년 10월 30일
Sorry I don't quite understand your question, do you mean you want to hide 'Tab2'?
If so you have to export .mlapp file to .m file, and modify code there with your flag to show or hide.
Hope this helps.

댓글을 달려면 로그인하십시오.


yumeng Jiang
yumeng Jiang 2019년 10월 30일
i want to hide the part in red circle,or do you know how to creat several panels overlapping but without inclusion relationship。
Inked1_LI.jpg

Adam Danz
Adam Danz 2020년 6월 19일
As of r2020a, there isn't an option to control the visibility or enable-property of individual tabs.
However, you can apply this demo to your app to control which tabs can be selected under different conditions. The demo prevents certain tabs from being selected according to the values of a set of checkboxes.
Demo:
  댓글 수: 1
Anna Zeng
Anna Zeng 2020년 6월 20일
Hi Adam, thank you for the answer! I think it's the best way to achive within App Designer.
In the end, my project switched to excel, where you can also use MATLAB (or VBA) to determine the rules to show or hide a tab, and easier to programme. Also, since my project is relatively big it would have 100000+ lines code if I use App Designer, then the app will become super slow.
Looking forward to MATLAB's future updates to make App Designer more powerful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Create Custom UI Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by