当前位置:网站首页>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);
}边栏推荐
- Implement is by yourself_ convertible
- Necessary skills for mobile terminal test: ADB command and packet capturing
- uniapp手机端uView的u-collapse组件高度init
- [cloud co creation] design Huawei cloud storage architecture with the youngest cloud service hcie (Part 1)
- Atof(), atoi(), atol() functions [detailed]
- 06. Libavdevice Library of ffmpeg
- 2020ICPC 江西省赛热身赛 E.Robot Sends Red Packets(dfs)
- 单点登录(一处登录,处处可用)
- FinClip实现微信授权登录的三种方案
- Obj file format and.Mtl file format
猜你喜欢

C100: smallest hevc visual IOT MCU

ThreadLocal

编程大杂烩(一)

Three schemes for finclip to realize wechat authorized login

Differences and application directions of GPS, base station and IP positioning

Necessary skills for mobile terminal test: ADB command and packet capturing

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

Win11 how to view the file explorer tab

Shenzhen on call test, subject 4 on call test, subject 3 theory, second theory on call test instructions

The difference between function and task in SystemVerilog
随机推荐
剑指offer专项突击版第9天
Samsung folding screen has sent samples to apple and Google, and the annual production capacity will be expanded from 2.4 million to 10million!
Game 302 of leetcode
Linear algebra (3)
Realsense d435i depth map optimization_ High precision mode
School day (summer vacation daily question 2)
Leetcode 237. 删除链表中的节点
What should testers do if they encounter a bug that is difficult to reproduce?
FinClip实现微信授权登录的三种方案
Arm PWN basic tutorial
ABC 261.D - Flipping and Bonus ( DP )
剑指 Offer 05. 替换空格
编程大杂烩(二)
Microservice gateway component
LCP plug-in creates peer-to-peer physical interface
Deep error
Implement is by yourself_ convertible
Leetcode 15: sum of three numbers
Leetcode 204. 计数质数(太妙了)
Necessary skills for mobile terminal test: ADB command and packet capturing