自定义QToolBox:标签高度 [英] Customizing QToolBox: tab height

查看:847
本文介绍了自定义QToolBox:标签高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以改变QToolBox小部件上标签的高度并使标题居中吗?

Is there any way to change the height of the tabs on a QToolBox widget and center the title?

我可以通过设置tabSpacing来更改高度,但是标题没有居中(顶部对齐).我尝试更改与样式表的对齐方式,但是没有运气.我还尝试通过以下方法强制高度:

I am able to change the height by setting tabSpacing, but then the title is not centered (it is top-aligned). I tried changing the alignment with the stylesheet but no luck. I also tried to force the height with:

QToolBox::tab {
     height: 48px;
     alignment: center;"
     margin: 0px 0px 0px 0px;"
}

但是它也不起作用.有什么想法吗?

BUt it is not working either. Any ideas?

推荐答案

与Qt支持人员交谈后,我发现的唯一方法是为所有选项卡分配一个空图标,并将图标大小设置为所需的高度./p>

After speaking with Qt support, the only way I found was to assign an empty icon to all tabs, and set the icon-size to the desired height.

...
for (int i = 0; i < ui->toolBox->count(); i++){
    ui->toolBox->setItemIcon( i, QIcon(":/shared/empty"));
}
ui->toolBox->setStyleSheet("QToolBox{ icon-size: 48px; }");
...

这篇关于自定义QToolBox:标签高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆