Trying to create a dialog class which will contain a QTableView widget, all is good, information gets inserted, but i cannot understand why pycharm show the error: "Unresolved attribute reference 'setModel' for class 'Dialog'"
all class code here:
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtWidgets import QDialog, QTableView
from PyQt5.uic import loadUi
class Dialog(QDialog):
def __init__(self):
super(Dialog, self).__init__()
loadUi("dialog.ui", self)
self.table = self.findChild(QTableView, "tableView")
def fill_table(self, data):
column_names = ["full_name", "mail", "age", "phone_number"]
model = QStandardItemModel(1, 4)
model.setHorizontalHeaderLabels(column_names)
for col_idx in range(4):
item = QStandardItem(data[col_idx])
model.setItem(0, col_idx, item)
self.table.setModel(model)
explain me what's going on and suggest solutions to the problem.
You can use type hints to make sure that pycharm knows the type of dynamically created objects:
or without the unecessary
findChild