How to create custom UI components with children for a MATLAB application?
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am designing a MATLAB application consisting of a UI figure with multiple tabs. Using MATLAB’s uitab and uitabgroup functions, the visual appearance of the application is quite austere, and tuning is very limited (for example, it is not possible to change the font weight/font size of the tab title).
To include more properties in my tabs, I’ve created new custom UI components "uitab2/uitabgroup2" using the base class "matlab.ui.componentcontainer.ComponentContainer", as described here. For uitab2 for example, the idea is to have something like uitab2(Parent,Name,Value) where:
- Name can be "FontSize" or "FontWeight" (in addition to the default tab properties such as "Position", "BackgroundColor", etc.),
- Parent should be a "uitabgroup2" object from the new defined class.
However, it seems that custom UI components cannot have children, and I get the error message "uitabgroup2 cannot be a parent of uitab2". Is there any hack to allow custom UI components to have children? Using a base class other than the component container, for instance?
0 Commenti
Risposte (1)
Githin George
il 13 Dic 2023
Hello Rafael Guichou,
It is my understanding that you would like to modify properties like fontSize, fontWeight for the “uitab” title.
These properties cannot be modified for ‘uifigure’ objects that are used in MATLAB App Designer. But the following workaround enables you to control some of the properties for MATLAB ‘figure’ objects.
f = figure;
tabGroup = uitabgroup(f);
% Use HTML formatting to specify font size
tab = uitab(tabGroup, 'Title', '<html><font size="12">Tab 1</font></html>');
% Use HTML formatting to specify font face
tab = uitab(tabGroup, 'Title', '<html><font face="Helvetica">Tab 1</font></html>');
Alternatively, you can use the MATLAB File Exchange submission “GUI Layout Toolbox” which provides more customizations on “uitab” properties. The link for the toolbox is provided below.
Please refer to the "paneltabexample.m" for an example of how tab panels can be created using this toolbox.
I hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Develop uifigure-Based Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!