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


相关推荐

  • 做了三年Java,java注释的三种形式

    做了三年Java,java注释的三种形式前言很多同学想进大厂,特别是刚毕业的,以及工作年限短的,不要有任何侥幸心理,踏踏实实的把基础弄扎实了,这是你通往高薪之路的唯一正确姿势。首先从面试题做起~好了,不多说了,直接上正菜。拼多多一面首先自我介绍参加过哪些项目并发编程三要素?实现可见性的方法有哪些?多线程的价值?创建线程的三种方式的对比?画出线程的状态流转图常用的并发工具类有哪些?CyclicBarrier和CountDownLatch的区别CAS的问题:1、CAS容易造成ABA问题2、不能保证代码块的原子

    2022年7月8日
  • GoLand 2021.7.20 x64 激活码(注册激活)

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

    2022年3月21日
  • 详细图解什么叫平方探查法即二次探测再散列和线性探测再散列(数据结构 哈希函数 哈希冲突)

    详细图解什么叫平方探查法即二次探测再散列和线性探测再散列(数据结构 哈希函数 哈希冲突)虽然上文有提到怎么解释的开放地址法处理hash冲突,但是当时只是给了个简单的图,没有详细讲解一下,我当时有点不明白,回头查查资料,然后亲自动手,整理了一下。然后我就三幅图详细讲解一下:什么叫线性探测再散列;什么叫平方探测再散列(二次探测再散列);老师的ppt吧。给个原始数据如上图。下面详细解析。上面的是线性探测再散列。这个简单。

    2022年5月15日
  • 各类加载loading动画效果

    各类加载loading动画效果效果一: 一、HTMLLoading…二、CSS/*绿色背景*/body{   background:#4ea980;   margin:50px;}/*纯白色圈*/.loader{   text-indent:-9999em;   position:relative;   width:200px;   height:20

    2022年4月19日
  • 词向量的作用

    词向量的作用      为了描述词与词之间的相似程度而构建的高维向量,而视频,音频数据构建本身意义,可以直接通过数据进行描述图像与声音的相似度。

    2022年5月17日
  • pycharm关闭自动补全_python opencv 教程

    pycharm关闭自动补全_python opencv 教程我刚下载pycharm,准备学opencv,然后在网上博客上找了许多文章看了,有的说下载后导入修改cv2文件夹里的_init_.py,但是经过测试也不行,个人感觉总是少了啥,然后找了许多文章看了然后也试了,除了安装opencv成功之外就没有了。后来看了许多文章之后看见每个博客写的方法都不一样,这里我就有点顿悟了…我看到cv2文件夹中的_init_.py里面的code已经说清楚啦,我是刚开始不怎么看得懂英文的意思,后来仔细看了才大概明白了一丢丢…请看:importimportlibimport

    2022年8月26日

发表回复

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

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