PyQt5 控件学习(一个一个学习之QDoubleSpinBox)

QDoubleSpinBox 继承图:

QDoubleSpinBox 描述:

它和QSpinBox 的整型差不多,无非就是整型和  浮点的区别,

但是它们并非继承关系 

QDoubleSpinBox 继承:

它的父类是QAbstractSpinBox  

QDoubleSpinBox 功能作用:

QDoubleSpinBox 功能作用之构造函数:

from PyQt5.Qt import * #刚开始学习可以这样一下导入
import sys

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("QDoubleSpinBox的学习")
        self.resize(400,400)
        self.set_ui()


    def set_ui(self):
        doubleSpinBox = QDoubleSpinBox(self)
        doubleSpinBox.resize(100,30)
        doubleSpinBox.move(100,30)
        # 它的默认的取值范围是 0.00- 99.00


if __name__ == '__main__':
    app =QApplication(sys.argv)

    window = Window()
    window.show()

    sys.exit(app.exec_())
View Code

QDoubleSpinBox 功能作用之设置数值范围:

这个和之前的QSpinBox 里的基本一致,只是数值的类型不同而已。

QDoubleSpinBox 功能作用之设置步长:

这个和之前的QSpinBox 里的基本一致,只是数值的类型不同而已。

QDoubleSpinBox 功能作用之前缀和后缀:

这个和之前的QSpinBox 里的基本一致,只是数值的类型不同而已

QDoubleSpinBox 功能作用之最小数值特殊文本:

看视频时的倍速框。

from PyQt5.Qt import * #刚开始学习可以这样一下导入
import sys

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("QDoubleSpinBox的学习")
        self.resize(400,400)
        self.set_ui()


    def set_ui(self):
        doubleSpinBox = QDoubleSpinBox(self)
        doubleSpinBox.resize(100,30)
        doubleSpinBox.move(100,30)

        doubleSpinBox.setRange(1.0,2.0)
        doubleSpinBox.setSingleStep(0.5)
        doubleSpinBox.setSuffix("倍速")  #设置后缀

        doubleSpinBox.setSpecialValueText("正常")

        doubleSpinBox.setWrapping(True)

        #设置小数位数 
        doubleSpinBox.setDecimals(1)  #保留一位小数
        print(doubleSpinBox.decimals())



if __name__ == '__main__':
    app =QApplication(sys.argv)

    window = Window()
    window.show()

    sys.exit(app.exec_())
View Code

QDoubleSpinBox 功能作用之设置小数位数:

上面已经说了

QDoubleSpinBox 功能作用之设置和获取数值:

QDoubleSpinBox 功能作用之自定义展示格式:

这个和之前的QSpinBox 里的基本一致,只是数值的类型不同而已

QDoubleSpinBox 信号:

这个和之前的QSpinBox 里的基本一致,只是数值的类型不同而已

有关重载:

重载,方法名称一样,但是参数的类型不同

总结: 

以上就是 QDoubleSpinBox ,下面看 QDataTimeEdit :https://www.cnblogs.com/zach0812/p/11387772.html

 

猜你喜欢

转载自www.cnblogs.com/zach0812/p/11387552.html