[英]PyQt5 QProgressBar border radius issue
I made a progress bar in PyQt5 designer with the following stylesheet:我使用以下样式表在 PyQt5 设计器中制作了一个进度条:
border: 2px solid black;
border-radius: 20px;
but there seems to be a graphical glitch where the bar does not round and the text is misaligned.但似乎存在图形故障,条形不圆且文本未对齐。
is this a known issue?这是一个已知的问题?
A .ui file if needed, could be easily replicated by dragging a progress bar in designer and using the stylesheet above.如果需要,可以通过在设计器中拖动进度条并使用上面的样式表轻松复制 .ui 文件。
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>289</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>90</x>
<y>110</y>
<width>201</width>
<height>61</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border: 2px solid black;
border-radius: 20px;</string>
</property>
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
You have to set the border radius on the QProgressBar chunk.您必须在 QProgressBar 块上设置边框半径。 I am not certain how it's done in .ui file but using qss it looks like this:
我不确定它是如何在 .ui 文件中完成的,但使用 qss 它看起来像这样:
QProgressBar {
border: 2px solid black;
border-radius: 20px;
text-align: center;
}
QProgressBar::chunk {
border-radius: 5px;
}
check out https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qprogressbar for other ways to customize the progress bar examples.查看https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qprogressbar了解自定义进度条示例的其他方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.