pyqt qlabel displays only first char of string

前端 未结 1 1705
青春惊慌失措
青春惊慌失措 2020-12-12 03:03

I want to display some string in QLabel on button click but my code only shows first char of the string. I am using following code for this

class UITesterWin         


        
相关标签:
1条回答
  • 2020-12-12 03:12

    The problem is caused because the size of the QLabel initially depends on the content of the text, and since this empty initially only takes the necessary width for a letter, the solution is to call the method adjustSize().

    def test3(self, data):
        self.SecondWindow.emailIDIN.setText("hello")
        self.SecondWindow.emailIDIN.adjustSize()
    

    Note: It is not advisable to have a variable that is named as a class since it can cause errors.

    0 讨论(0)
提交回复
热议问题