PyQt5 QLCD数字显示

PyQt5 QLCDNumber Display

我是 PyQt5 的新手,已经玩了大约两周了,我遇到了 QLCDNumber 显示方法的问题。我希望能够显示超过 5 位数字,而我目前无法使用我的代码显示这些数字。在我输入第 6 位数字后,数字停止显示。 我在 google 和 youtube 上研究了大约一个星期,但未能找到解决方案。 代码:

self.lcd = QLCDNumber(self)
self.lcd.setGeometry(3, 120, 150, 30)
self.lcd.display(91029)

上面的代码有效,但下面的代码不显示数字:

self.lcd = QLCDNumber(self)
self.lcd.setGeometry(3, 120, 150, 30)
self.lcd.display(910297)

正如 the docs 指出的那样:

digitCount : int

This property holds the current number of digits displayed

Corresponds to the current number of digits. If QLCDNumber::smallDecimalPoint is false, the decimal point occupies one digit position.

By default, this property contains a value of 5.

This property was introduced in Qt 4.6.

Access functions:

int digitCount()
const void setDigitCount(int numDigits)

(强调我的)

默认情况下,最多只显示 5 个数字,所以如果你想显示更多或更少的数字,你必须使用 X 方法或在构造函数中指向它:

self.lcd = QLCDNumber(6, self)
self.lcd.setGeometry(3, 120, 150, 30)
self.lcd.display(910297)

self.lcd = QLCDNumber(self)
self.lcd.setGeometry(3, 120, 150, 30)
self.lcd.setDigitCount(6)
self.lcd.display(910297)