pythonpyqtpyqt5qlcdnumber

Pyqt5 QLCDNumber is not showing seconds (third object)


I have a QLCDNumber I need to show 3 parts (hrs:minutes:seconds). So, I set it as lcdnumber.display("00:00:00"), it show only two parts (00:00). I think the problem is with ":". I tried to separate and use text manipulation, it didn't work, only shows the first two parts. How can I show the third part of seconds.


Solution

  • You have to set the number of digits you want to display using the digitCount property, in this case it must be 8 (6 for the zeros and 2 for ":"):

    from PyQt5 import QtWidgets
    
    if __name__ == "__main__":
        app = QtWidgets.QApplication([])
    
        w = QtWidgets.QLCDNumber()
        w.setDigitCount(8)
        w.display("00:00:00")
        w.resize(640, 120)
        w.show()
    
        app.exec_()
    

    enter image description here