当前位置:网站首页>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);
}边栏推荐
- Realsense D435i 深度图优化_高精度模式
- 微服务及相关组件概念
- C Programming -- the solution of dynamic programming of "the sum of the largest subarray"
- Adaptation dynamics | in June, sequoiadb completed mutual certification with five products
- Preliminary understanding of Panda3D particle system
- Programming hodgepodge (II)
- OpenFegin远程调用丢失请求头问题
- 聊聊 Redis 是如何进行请求处理
- Is the Huatai account opened by qiniu safe to use?
- 2020ICPC 江西省赛热身赛 E.Robot Sends Red Packets(dfs)
猜你喜欢

How to carry out the function test with simple appearance and complex interior?

Vim查找替换及正则表达式的使用

What content does the software test plan include and how to write it. Share test plan template

ThreadLocal

Single sign on (one sign on, available everywhere)

systemverilog中function和task区别

Project management tools - project developer tools

微服务 - Hystrix 熔断器

Unity accesses chartandgraph chart plug-in

50:第五章:开发admin管理服务:3:开发【查询admin用户名是否已存在,接口】;(这个接口需要登录时才能调用;所以我们编写了拦截器,让其拦截请求,判断用户是否是登录状态;)
随机推荐
background
FinClip实现微信授权登录的三种方案
传输线理论之相速、相位等的概念
Continuous maximum sum and judgement palindrome
Leetcode 237. delete nodes in the linked list
systemverilog中function和task区别
Working principle and precautions of bubble water level gauge
Anshi semiconductor management paid a visit to Wentai technology and Gree Electric appliance
50:第五章:开发admin管理服务:3:开发【查询admin用户名是否已存在,接口】;(这个接口需要登录时才能调用;所以我们编写了拦截器,让其拦截请求,判断用户是否是登录状态;)
ThreadLocal
Solution of win11 blue screen code 0x0000001a
odoo14 | 关于状态栏statusbar关键词使用后显示异常及解决方法
Openfegin remote call lost request header problem
Leetcode 202. 快乐数(一点都不快乐)
Programming hodgepodge (I)
深圳随到随考,科目四随到随考,科三理论第二理论随到随考说明
Single sign on (one sign on, available everywhere)
Leetcode 15: sum of three numbers
2020ICPC 江西省赛热身赛 E.Robot Sends Red Packets(dfs)
LCP插件创建对等物理接口