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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 女人喜欢大男人还是小男人

    女人喜欢大男人还是小男人 转载自 http://hi.baidu.com/512347937/blog/item/6651e4cdec149c510eb3452c.html      大男人,小男人,到底谁能满足现代女人?现代女人首先取悦的是自己,然后才是男人,不管是大人,还是小男人,他们是他们,她是她自己。她为自己做这一切,她应该享有完美的人生。  经常有人问:你觉得什么是大男人,什么是小男人?  一般

    2022年7月25日
    8
  • glassfish配置错误问题「建议收藏」

    glassfish配置错误问题「建议收藏」当脱开netbeans单独运行glassfishweb服务器后:(运行glassfish服务器cmd下asadminstart-domain服务器就开始运行)浏览页面出现org.apache.jasper.JasperException:PWC6345:Thereisanerrorininvokingjavac.AfullJDK(notjustJ…

    2022年8月20日
    6
  • psd 替换智能图层的的实现-个性化定制网站

    psd 替换智能图层的的实现-个性化定制网站老板让做一个在线服装定制的网站,可合成服装的效果图遇到了难处,如果是单纯的图片叠加也比较简单,前端合成的话使用canvas两张图片合成在一起就可以了canvas合成衣服的效果图准备两张图片,一张是素材,一张是背景如下图他们加一块就得到了这样一张图满心欢喜找老板,实现了!!!,终于可以早早下班了,然并卵,老板说:素材为啥没有弯曲,做出来的图片不真实,方案被打回来之后再次研究方案1.弯曲写死,如果单纯定制杯子是没有问题的,因为他只有一种效果,如果定制的是衣服,风景画等等其他的商品效.

    2022年5月16日
    36
  • Σ求和符号_西格玛符号怎么打

    Σ求和符号_西格玛符号怎么打转自:https://zh.wikipedia.org/wiki/%E6%B1%82%E5%92%8C%E7%AC%A6%E5%8F%B7求和符号(Σ,sigma),是欧拉于1755年首先使用的。这个符号是源于希腊文σογμαρω(增加)的字头,Σ正是σ的大写。求和的结果是给定的数值相加后的总值,又称加总。举例而言,若有4个数值:1、3、5、7,则这4个数值的总和为:

    2022年10月9日
    2
  • mac goland激活码[最新免费获取]

    (mac goland激活码)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月29日
    178
  • tomcat7配置教程_Tomcat热部署

    tomcat7配置教程_Tomcat热部署1.Tomcat依赖于JDK,需要提前安装好JDK,参考另外一篇文章:JAVA安装部署2.到官网下载Tomcat7,解压到相关路径即可。Tomcat官网3.从Tomcat7之后的版本都不需要配置环境变量,在bin目录下,查看starup.bat:意思是如果bin目录下面存在catalina.bat文件,就可以访问tomcat页面了,代表安装成功了。PS:如果没…

    2025年6月13日
    2

发表回复

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

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