如何在QT中获得具有圆角边缘和圆角进度边缘的QProgressBar



我创建了一个垂直进度条,并尝试用圆角边缘设置它。无论我做什么,我似乎都无法获得带有圆角边缘的进度条(QProgressBar::chunk)的进度或块。请帮助我,我是QT的新手。

请在下面找到我的代码:-

progressbar_V = new QProgressBar;
progressbar_V->setParent(this);
progressbar_V->setMinimum(0);
progressbar_V->setMaximum(5);
progressbar_V->setValue(3);
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
progressbar_V->setGeometry(250,250,60,300);
progressbar_V->setOrientation(Qt::Vertical);

进度条文本也位于输出的顶部。我将如何将其放在垂直进度条的中间

你是对的,你可以使用这个参数:

border-radius: 50px;

获得圆形边界!但是您只是忘记在最后指定px

因此,一旦您的代码更新,它看起来像这样:

progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12px; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");

您需要将样式表更改为如下所示的内容:

progressbar_V->setStyleSheet("QProgressBar{ 边框:纯灰色;边框右下半径:12px;边框左下半径:12px;颜色:黑色;文本对齐:居中;},QProgressBar::chunk {background-color: #05B8CC;border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;}");

快乐编码..

最新更新