PyQt5 QLCDNumber Display

2.8k Views Asked by At

I´m new to PyQt5 have been playing with it for about two weeks now and I have encountered an issue with the QLCDNumber display method. I want to be able to display more than 5 digits which I currently can´t with the code I have. After I input the 6th digit the numbers stop showing. I have researched for about a week on google and youtube but was not able to find a solution. Code:

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

This above code works but the below does not display the numbers:

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

There are 1 best solutions below

2
On BEST ANSWER

As the docs points out:

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)

(emphasis mine)

As indicated by default, only up to 5 digits are shown, so if you want to show more or less digits you must use the X method or point it in the constructor:

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

or

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