Can I hide a tab in MATLAB App Designer?

97 vues (au cours des 30 derniers jours)
Anna Zeng
Anna Zeng le 17 Oct 2019
Commenté : Anna Zeng le 20 Juin 2020
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

Réponse acceptée

Anna Zeng
Anna Zeng le 17 Oct 2019
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 commentaires
yumeng Jiang
yumeng Jiang le 30 Oct 2019
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 le 30 Oct 2019
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

Connectez-vous pour commenter.

Plus de réponses (5)

yumeng Jiang
yumeng Jiang le 30 Oct 2019
hi do you know how to hide the title of tabgroup???
  1 commentaire
Anna Zeng
Anna Zeng le 30 Oct 2019
Hi, I believe my answer above is the solution, but please let me know if you have better idea. Thanks!

Connectez-vous pour commenter.


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

Connectez-vous pour commenter.


yumeng Jiang
yumeng Jiang le 30 Oct 2019
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 commentaire
Anna Zeng
Anna Zeng le 30 Oct 2019
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.

Connectez-vous pour commenter.


yumeng Jiang
yumeng Jiang le 30 Oct 2019
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
  1 commentaire
Inso
Inso le 3 Déc 2019
Try " app.Tab.Title=' '; "

Connectez-vous pour commenter.


Adam Danz
Adam Danz le 19 Juin 2020
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 commentaire
Anna Zeng
Anna Zeng le 20 Juin 2020
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Create Custom UI Components dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by