Can I hide a tab in MATLAB App Designer?

93 Ansichten (letzte 30 Tage)
Anna Zeng
Anna Zeng am 17 Okt. 2019
Kommentiert: Anna Zeng am 20 Jun. 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

Akzeptierte Antwort

Anna Zeng
Anna Zeng am 17 Okt. 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 Kommentare
yumeng Jiang
yumeng Jiang am 30 Okt. 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 am 30 Okt. 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (5)

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

Melden Sie sich an, um zu kommentieren.


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

Melden Sie sich an, um zu kommentieren.


yumeng Jiang
yumeng Jiang am 30 Okt. 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 Kommentar
Anna Zeng
Anna Zeng am 30 Okt. 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.

Melden Sie sich an, um zu kommentieren.


yumeng Jiang
yumeng Jiang am 30 Okt. 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

Adam Danz
Adam Danz am 19 Jun. 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 Kommentar
Anna Zeng
Anna Zeng am 20 Jun. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Create Custom UI Components 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!

Translated by