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.

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • C#中FileStream与StreamReader/StreamWriter区别

    C#中FileStream与StreamReader/StreamWriter区别FileStreamFileStream类不是静态类,表示在磁盘或网络路径上指向文件的流。这个类提供了在文件中读写字节的方法,但经常使用StreamReader或StreamWriter执行这些功能。这是因为FileStream类操作的是字节和字节数组,而Stream类操作的是字符数据。使用时需要创建对象,FileStream类既可以对文本文件进行读也可以对多媒体文件进行写,以字节数组的形式进…

  • shell循环读取文件拼接字符串

    shell循环读取文件拼接字符串1注意通道和重定向的区别通道会开启子shell,于是通道语句块内的变量修改是无法影响到其外的变量的,故使用重定向;2windows文件末尾是/r/n拼接来自windows系统的文件务必首先注意:[nash5camFiles]#cat-AcamFiles.ori0.863631-0.269646-0.425949^M$

  • eigen使用教程_kafka简单使用

    eigen使用教程_kafka简单使用Eigen是可以用来进行线性代数、矩阵、向量操作等运算的C++库,它里面包含了很多算法。它的License是MPL2。它支持多平台。Eigen采用源码的方式提供给用户使用,在使用时只需要包含Eigen的头文件即可进行使用。之所以采用这种方式,是因为Eigen采用模板方式实现,由于模板函数不支持分离编译,所以只能提供源码而不是动态库的方式供用户使用。矩阵的定义:E…

    2022年10月18日
  • ElasticSearch教程_Elasticsearch原理

    ElasticSearch教程_Elasticsearch原理Elasticsearch是一个分布式的RESTful风格的搜索和数据分析引擎。查询:Elasticsearch允许执行和合并多种类型的搜索—结构化、非结构化、地理位置、度量指标—

  • 联想开天 N7 评测

    联想开天 N7 评测开天N7系列笔记本电脑基于兆芯开先KX-6640MA处理器平台,搭配16GB双通道内存和512GBNVMe高速SSD,辅以国产BIOS、OS定制调优;1.29kg超轻单机重量,14.6mm极致纤薄全金属机身;14英寸2.2k16:10显示屏,91%屏占比;支持单手极限180度开盖;率先在国产笔记本引入WiFi6和蓝牙5.0;搭配联想专用芯片的创新智能控制方案,具备光感自动化、开盖即开机、快速充电、充电宝模式等多重独有功能;双风扇双热管散热系统,搭配61Wh

  • JAVA获取uuid_java uri类

    JAVA获取uuid_java uri类UUID获取以及格式化没有什么描述的直接看代码

发表回复

您的电子邮箱地址不会被公开。

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