Can I hide a tab in MATLAB App Designer?

98 次查看(过去 30 天)
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 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by