qtablewidget设置滚动条样式_word滚动条作用

qtablewidget设置滚动条样式_word滚动条作用IhaveaQTabWidgetwithtoomanytabsandtheyoverflowwithscrollerarrows.Iwanttoincreasethewidthofthescrollerarrowsbymorethantwiceofthedefaultwidthsotheyareeasiertouseona…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

qtablewidget设置滚动条样式_word滚动条作用

I have a QTabWidget with too many tabs

85f53f68e7e2cd2ed04607b6435f43aa.png

and they overflow with scroller arrows. I want to increase the width of the scroller arrows by more than twice of the default width so they are easier to use on a touchscreen.

There is a QTabWidget StyleSheet example but I cannot seem to get it to work nicely. The stylesheet below produces this screenshot

4a34e08ac14070fa9a7f5d8b0e942707.png

QTabBar::scroller { /* the width of the scroll buttons */

width: 40px;

}

QTabBar QToolButton { /* the scroll buttons are tool buttons */

width: 15px;

border-width: 2px;

}

where I would like something like this screenshot I edited.

e95bcdf0efe1659aacc4380094d5e2d8.png

解决方案

Method #1: This appears to be a bug, plain and simple. The background of the buttons is transparent; but setting it to white via a style sheet and setting the widths aren’t working right either.

I was able to solve the problem by using a style sheet thus:

QTabBar::scroller {width: 0px;}

If it don’t work: get rid of it. Then, I created two buttons with which to scroll it right, and laid the tab widget and buttons out horizontally. I set the padding of enclosing vertical and horizontal layouts to zero. I labelled the buttons “”, but u can git fancier if u want. If you want to have the tab area below the scroll bar the same width as the tab bar and the buttons, you need two tab widgets:

QTabWidget1 Button1 Button2

Wider QTabwidget2

Then, you set the height of QTabWidget1 so only the tabs show, and set QTabWidget2’s tab bar height to 0 with a stylesheet:

QTabBar::tab {height: 0px;}

so only the bodies of the tabs show; not the tabs themselves.

Since they aren’t thoughtful enough to expose a scroll method for the tab bar, you can fudge it by just changing the active tab via setCurrentIndex(); and it will stay in view.

You can then activate or de-activate the < and > buttons, depending on if the first or the last tab is already active. I’m not bothering to hide them nor disable them, since my app is mostly calculation and little polish.

Yes, it’s a PITA. If there’s no better way around it, just code around it. If life hands you a lemon, make lemon bombs, and show it who’s boss. (Actually, almost always figuratively, only.) I’ll submit a bug report one of these days, when I get time.

Maybe there are magic propert(ies) that can get those buttons to have normal backgrounds and sizes; but I don’t know them.

Edit: Method #2: Solved my problem, but won’t OP’s (for those experiencing the same problem. I came here because of this problem when I wasn’t trying to restyle these buttons. This is a known bug when using a stylesheet that a QTabBar either has or inherits: “When adding a style sheet to the tabs the navigation scroll arrow buttons become transparent”. (Vote for this issue, and it’ll get fixed faster.) Simply doing without the stylesheet solved my problem. Mine was on the parent form; and removing it and applying it to the element I wanted styled only, fixed it.

Method #3: You might try setting such properties as button width using non-stylesheet properties until it gets fixed; although I believe it’ll mean subclassing the QTabWidget and QTabBar to access the QToolButton properties. It sounds worse than it is. You might can accomplish it with about a dozen lines of code in the header; although if you use Qt Creator in the Design tab, or Designer, you’ll need to promote the tab widget.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/190426.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 从零开始学android编程之网格布局管理器(2-1)

    从零开始学android编程之网格布局管理器(2-1)网格布局管理器用GridLayout类来表示。在《从零开始学android编程之表格布局管理器》中提到的TableLayout一般产生的表格外形是标准的方框,而GridLayout类产生的网格可以是不标准的。1设置网格的行数和列数在《从零开始学android编程之线性布局管理器》中提到的activity_linear.xml文件中使用表格布局管理器GridLayout,代码如下Lin

    2022年5月7日
    55
  • 循环-15. 统计素数并求和(20)

    循环-15. 统计素数并求和(20)

    2022年2月2日
    42
  • N70/N72常见问题汇总

    N70/N72常见问题汇总引自:http://bbs.imobile.com.cn/viewthread.php?tid=1092547这里是一些常见的问题,求助前请看里面有没有你需要的答案,或者善用论坛的搜索功能已更新至第四楼为什么我看不到手机或内存卡上的system文件夹?在手机上看这个文件夹需要安装第三方文件管理软件fileman、SeleQ、Fexplorer等文件管理软件如果要在电脑上看到这个文件夹需要将卡…

    2022年7月11日
    17
  • 国产自动化测试工具「建议收藏」

    国产自动化测试工具「建议收藏」软件测试工具一直是国外的占据了主流!国内鲜有自主研发的。但是最近几年国内逐渐出现了几个,也许发展下去可以与国外主流软件测试工具厂商一较高下。 AutoRunnerhttp://www.spasvo.com/泽众软件TAR终端自动化测试工具宣称是国内最好的银行业务测试工具。 Tester360http://www.tester360.com/亚

    2022年6月5日
    54
  • 像素密度(衡量屏幕显示能力)

    像素密度(衡量屏幕显示能力)像素密度=√[(长度像素数)^2+(宽度像素数)^2]/屏幕尺寸eg:

    2022年5月17日
    46
  • oracle10g在win10上的安装

    oracle10g在win10上的安装一、下载官网下载地址: https://www.oracle.com/downloads/index.html#menu-downloads或者:链接:http://pan.baidu.com/s/1cGr3PW密码:oz8n下载解压后得到:三个安装包:PL/SQLDe

    2022年10月9日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号