PyQt4:在QTabWidget中设置选项卡栏的大小 [英] PyQt4: Set size of the tab bar in QTabWidget

查看:683
本文介绍了PyQt4:在QTabWidget中设置选项卡栏的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改QTabWidget中选项卡栏的高度?

How would you change the height of the tab bar in a QTabWidget?

推荐答案

您应该创建一个自定义的QTabBar并覆盖其tabSizeHint方法.然后使用QTabWidget.setTabBar方法将自定义的QTabBar设置为QTabWidget的条形.

You should create a customized QTabBar and overwrite its tabSizeHint method. Then set that customised QTabBar as the bar of your QTabWidget using the QTabWidget.setTabBar method.

我认为以下(未经测试的)代码可以为您提供帮助:

I think the following (non tested) code could help you:

class TabBar(QTabBar):

   def tabSizeHint(self, index):
       width = QTabBar.tabSizeHint(self, index).width()
       return QSize(width, your_wanted_height)

您可以在此处找到其他自定义示例.

You can find other customization examples here.

这篇关于PyQt4:在QTabWidget中设置选项卡栏的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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