gpt4 book ai didi

qt - QLineEdit 内容圆角的样式表?

转载 作者:行者123 更新时间:2023-12-03 22:46:14 40 4
gpt4 key购买 nike

我正在使用 Qt 样式表创建一个自定义 QLineEdit,当它有焦点时,它周围有一个浅蓝色边框。这是样式表:

    this->setStyleSheet(" QLineEdit { "
" border-radius: 4px; "
" color:rgb(0, 0, 0); "
" background-color: rgb(255, 255, 255); } "

" QLineEdit:focus { "
" border-style:outset; "
" border-width:4px; "
" border-radius: 4px; "
" border-color: rgb(41, 237, 215); "
" color:rgb(0, 0, 0); "
" background-color: rgb(150, 150, 150); } "
);

结果如下:

enter image description here

这看起来很不错,但是有什么方法可以使 QLineEdit 内容区域的角变圆?上图中的浅灰色区域?

更具体地说,这可以与 Qt 样式表有关吗?

最佳答案

border-radius应该大于border-width至少 4-5 像素。尝试以下操作:

this->setStyleSheet(" QLineEdit { "
" border-radius: 8px; "
" color:rgb(0, 0, 0); "
" background-color: rgb(255, 255, 255); } "

" QLineEdit:focus { "
" border:4px outset; "
" border-radius: 8px; "
" border-color: rgb(41, 237, 215); "
" color:rgb(0, 0, 0); "
" background-color: rgb(150, 150, 150); } "
);

好像:

enter image description here

关于qt - QLineEdit 内容圆角的样式表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23121943/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com