gpt4 book ai didi

matlab - 如何控制 uitable headers 的样式?

转载 作者:行者123 更新时间:2023-12-04 10:59:44 25 4
gpt4 key购买 nike

考虑以下向 UIFigure 添加表格的代码:

hF = uifigure();
hT = uitable(hF, 'Position',[1 1 72 112], ...
'Data', [ (5:5:20).' + "K", 100+zeros(4,1) + "%" ], ...
'ColumnName', [compose("\x0394T"), "SR"], 'RowName', [],...
'ColumnWidth', {30,40});
addStyle( hT, uistyle('HorizontalAlignment', 'center')); % Added in R2019b

这导致:

enter image description here

正如你在上面看到的,表格的标题仍然是左对齐的,并且字体比内容小——这看起来很不舒服。我希望标题居中对齐并具有相同或更大的字体大小。

我的问题是: 如何更改标题的文本对齐方式和字体大小?

我正在使用 R2019b 更新 1。

最佳答案

这可以通过执行几个修改 <div class="mw-default-header-cell"> 样式的 JS 命令来完成。元素:

% Get a webwindow handle:
hWin = struct(struct(struct(hF).Controller).PlatformHost).CEF;

% Execute some dojo commands:
hWin.executeJS('W = dojo.query("div[class=mw-default-header-cell]");');
hWin.executeJS('dojo.style(W[0], ''text-align'', ''center'');');
hWin.executeJS('dojo.style(W[1], ''text-align'', ''center'');');
hWin.executeJS('dojo.style(W[0], ''font-size'', ''12px'');');
hWin.executeJS('dojo.style(W[1], ''font-size'', ''12px'');');

导致:

enter image description here

请注意 dojo.query("div[class=mw-default-header-cell]")检索 全部 div 是表格标题,因此如果 UIFigure 中有多个表格,或者标题一个不想修改,则必须注意索引( W )进行修改。

关于matlab - 如何控制 uitable headers 的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58901340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com