Answer the question
In order to leave comments, you need to log in
In the program, setText() does not display a value, why?
I wrote a simple program on the form of a button and an empty label, I want to change the text in the label by pressing the button, but something doesn’t work, tell me please ..
from PyQt5 import uic
from PyQt5 import QtWidgets
import sys
Form, Window =uic.loadUiType("untitled.ui")
class Ui (QtWidgets.QDialog, Form):
def __init__(self):
super(Ui, self).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.printButtonPressed)
def printButtonPressed(self):
self.label.setText("hello")
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = Window()
form = Form()
form.setupUi(window)
window.show()
app.exec()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question