Qt 增加 QTabWidget 的 QTabBar 大小 [英] Qt Increase QTabWidget's QTabBar size

查看:494
本文介绍了Qt 增加 QTabWidget 的 QTabBar 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使我在 QTabWidget 底部定向的选项卡更大.我们将使用触摸屏,因此默认尺寸有点太小.

I need to make the tabs that I have oriented at the bottom of my QTabWidget larger. We'll be using a touch-screen, so the default sizes are a little too small.

我认为没有简单的方法可以做到这一点(目前根本看不到什么好的方法.我在 QTabWidget 中看到的与 QTabBar 相关的唯一方法是受保护的,我认为不需要继承自用于此明确目的以外的类).

I see no easy way to do this (currently seeing no good way to even do it at all. The only methods pertaining to the QTabBar that I see in QTabWidget are protected, and I don't see a need to inherit from the class other than for this express purpose).

问题:

我想做的只是将 QTabBar 设置为某个特定大小.这可能吗?

What I'd like to do is to just set the QTabBar to a certain specific size. Is this possible?

除此之外,我唯一能想到的就是将 QTabWidget 子类化,然后我可以通过扩展或覆盖此类的功能来控制 QTabBar 的大小.

Other than this, the only thing I can think of is to subclass QTabWidget and then I can control the size of the QTabBar by extending or overriding features of this class.

谢谢.

推荐答案

如果你不想子类化的东西,你可以使用 Qt 样式表 可以像这样快速设置标签的高度和宽度:

If you don't want to subclass stuff, you can use Qt stylesheets to quickly set the height and width of your tabs like so:

// tabWidget is a pointer to a QTabWidget
tabWidget->setStyleSheet("QTabBar::tab { height: 100px; width: 100px; }");
// each tab should now be 100x100px

请注意,即使我们在 QTabWidget 上调用 setStyleSheet(),样式表也引用了 QTabBar.

Note that the stylesheet refers to QTabBar even though we're calling setStyleSheet() on QTabWidget.

这篇关于Qt 增加 QTabWidget 的 QTabBar 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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