mirror of
https://github.com/maicss/PyQt5-Chinese-tutorial.git
synced 2025-01-24 21:12:54 +08:00
~
This commit is contained in:
commit
96a62dab49
5
自定义控件.md
5
自定义控件.md
@ -155,7 +155,7 @@ if __name__ == '__main__':
|
||||
ex = Example()
|
||||
sys.exit(app.exec_())
|
||||
```
|
||||
In our example, we have a QSlider and a custom widget. A slider controls the custom widget. This widget shows graphically the total capacity of a medium and the free space available to us. The minimum value of our custom widget is 1, the maximum is 750. If we reach value 700, we begin drawing in red colour. This normally indicates overburning.
|
||||
本例中,我们使用了`QSlider`和一个自定义组件。 and a custom widget. A slider controls the custom widget. This widget shows graphically the total capacity of a medium and the free space available to us. The minimum value of our custom widget is 1, the maximum is 750. If we reach value 700, we begin drawing in red colour. This normally indicates overburning.
|
||||
|
||||
The burning widget is placed at the bottom of the window. This is achieved using one QHBoxLayout and one QVBoxLayout.
|
||||
```
|
||||
@ -202,5 +202,4 @@ def changeValue(self, value):
|
||||
```
|
||||
When we move the slider, the changeValue() method is called. Inside the method, we send a custom updateBW signal with a parameter. The parameter is the current value of the slider. The value is later used to calculate the capacity of the Burning widget to be drawn. The custom widget is then repainted.
|
||||
|
||||
The burning widget
|
||||
Figure: The burning widget
|
||||
![burning widget](./image/10-burning.png)
|
Loading…
x
Reference in New Issue
Block a user