How to create custom UI components with children for a MATLAB application?
22 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Githin George
2023-12-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!