当前位置:网站首页>QT qtextedit setting qscrollbar style sheet does not take effect solution
QT qtextedit setting qscrollbar style sheet does not take effect solution
2022-07-25 05:35:00 【Stroll along the bustling street】
stay UI Reference inside QTextEdit Control , When designing its style , Usually it will also scroll bar (
horizontalScrollBar、verticalScrollBar) Design styles .
For example, we are right QTextEdit Vertical scroll bar for style design , The style sheet will write like this :
QTextEdit#textEdit
{
background:rgba(0,0,0,0.1);
color:rgba(255,255,255,0.8);
border-radius:2px;
border:none;
font-size:14px;
font-family:" Microsoft YaHei ";
}
QScrollBar:vertical
{
border: none;
background: transparent;
width: 6px;
}
QScrollBar::handle:vertical
{
background-color: rgba(255,255,255,1);
min-height: 30px;
border-radius:3px;
width: 6px;
}
QScrollBar::add-line:vertical
{
border: none;
height: 0px;
}
QScrollBar::sub-line:vertical
{
border: none;
height: 0px;
}
QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical
{
background:transparent;
border-radius:3px;
}stay Qt Designer It looks normal inside , Pictured :

But when running the program (Ctrl + R) when , The stylesheet does not take effect , Pictured :

============================ Solution =================================
programme 1: In the constructor of the class, the scroll bar is polish Polishing operation .
ReadingTimeSettingDialog::ReadingTimeSettingDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::ReadingTimeSettingDialog)
{
ui->setupUi(this);
ui->textEdit->verticalScrollBar()->style()->polish(ui->textEdit->verticalScrollBar());
}
programme 2:
(1) take QTextEdit The original scroll bar is hidden , Setting scroll bar policy is not ScrollBarAlwaysOff

(2) Add new control Vertical Scroll Bar Put in QTextEdit The left side of the

(3) Set up verticalScrollBar The style sheet of
(4) Set in the constructor verticalScrollBar by QTextEdit Scroll bar
ReadingTimeSettingDialog::ReadingTimeSettingDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::ReadingTimeSettingDialog)
{
ui->setupUi(this);
ui->textEdit->setVerticalScrollBar(ui->verticalScrollBar);
}边栏推荐
- idea常用10个快捷键
- Leetcode 237. 删除链表中的节点
- 批量下载视频小技巧
- Programming hodgepodge (I)
- 微服务 - 配置中心 - Nacos
- ABC 261.D - Flipping and Bonus ( DP )
- 求求你别再用 System.currentTimeMillis() 统计代码耗时了,真的太 Low 了!
- Microservice gateway component
- Redis cluster setup (Windows)
- The selection reference of Junzheng T41, T40 and T31 versions are all here
猜你喜欢

50:第五章:开发admin管理服务:3:开发【查询admin用户名是否已存在,接口】;(这个接口需要登录时才能调用;所以我们编写了拦截器,让其拦截请求,判断用户是否是登录状态;)

Adaptation dynamics | in June, sequoiadb completed mutual certification with five products

Microservices and related component concepts

Panda3D keyboard moving scene

Leetcode 237. delete nodes in the linked list

Unity accesses chartandgraph chart plug-in

Implement is by yourself_ class

Thesis reading | which is the best multilingual pre training technology for machine translation? See the latest progress!

Implement is by yourself_ convertible

自己实现is_base_of
随机推荐
flex布局常用属性总结
微信小程序相关操作示例
弹性布局总结
Leetcode 204. count prime numbers (wonderful)
Concepts of phase velocity and phase in transmission line theory
Zhanrui's first 5g baseband chip was officially released and successfully ranked among the first tier of 5g!
自己实现is_class
Linear algebra (3)
项目管理工具——阿里云Projex介绍与实战
Adaptation dynamics | in June, sequoiadb completed mutual certification with five products
How to carry out the function test with simple appearance and complex interior?
OpenFegin远程调用丢失请求头问题
Anshi semiconductor management paid a visit to Wentai technology and Gree Electric appliance
easyrecovery免费数据恢复工具操作简单一键恢复数据
LCP插件创建对等VLAN接口
深圳随到随考,科目四随到随考,科三理论第二理论随到随考说明
Switch NPM source to private source library
Add click event to unity 3D object
STL notes (VI): container vector
微服务及相关组件概念