当前位置:网站首页>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);
}边栏推荐
- SystemVerilog中interface(接口)介绍
- 自己实现is_class
- Working principle and precautions of bubble water level gauge
- Introduction summary of using unirx in unity
- CSDN编程挑战赛之数组编程问题
- 传输线理论之相速、相位等的概念
- 项目管理工具——阿里云Projex介绍与实战
- Unity accesses chartandgraph chart plug-in
- 2020icpc Jiangxi warm up e.robot sends red packets (DFS)
- background
猜你喜欢

CCID released the "Lake warehouse integrated technology research report", and Jushan database was selected as a typical representative of domestic enterprises

50 places are limited to open | with the news of oceanbase's annual press conference coming!

传输线理论之相速、相位等的概念

FinClip实现微信授权登录的三种方案

Microservice - hystrix fuse

Easyrecovery free data recovery tool is easy to operate and restore data with one click

The third day of rhcsa summer vacation

Leetcode 202. happy number (not happy at all)

What about reinstalling win11 system?

Odoo14 | about the abnormal display of statusbar keyword after use and Its Solutions
随机推荐
C编程 --“最大子数组的和” 的动态规划的解法
Atof(), atoi(), atol() functions [detailed]
批量下载视频小技巧
Powering 5g notebook market, Wentai technology joined the "Honghu plan"
项目管理工具——阿里云Projex介绍与实战
SystemVerilog中interface(接口)介绍
2021 ICPC Shaanxi warm up match b.code (bit operation)
LCP插件创建对等物理接口
Leetcode 202. happy number (not happy at all)
Introduction to interface in SystemVerilog
Uniapp custom application exit execution content
自己实现is_convertible
Deep error
obj文件格式与.mtl文件格式
STL notes (IV): String
The global shipment of glory 8x series exceeded 10million units, and the glory V20 exceeded 1.5 million units!
Solution of win11 blue screen code 0x0000001a
深圳随到随考,科目四随到随考,科三理论第二理论随到随考说明
Leetcode 204. 计数质数(太妙了)
Microservice configuration center Nacos