PyCharm loadUi findChild - unresolved attribute reference

31 Views Asked by At

I use PyCharm and imported an Qt Designer ".ui" with PyQt6:

from PyQt6 import QtWidgets, uic

class Ui(QtWidgets.QMainWindow):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('C:/Users/M/PycharmProjects/2021-12-15_book table/book.ui', self)

        self.pushButton_1 = self.findChild(QtWidgets.QPushButton, "pushButton_1")
        self.pushButton_1.setText('add book')
        self.pushButton_1.clicked.connect(self.add_book)
        #[...]

app = QtWidgets.QApplication(sys.argv)
window = Ui()
app.exec()

PyCharm always shows the errors

  • "Unresolved attribute reference 'setText' or 'Ui' and
  • "Unresolved attribute reference 'connect' or 'Ui' so my understanding is that .findChild does not work.

Do you have an idea how so solve that?

0

There are 0 best solutions below