0

i am probably missing something small

so the main window that calls my qt-designer layout looks like this

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.setWindowState(Qt.WindowMaximized)

in the qt designer pyqt file there is a table view

self.surveys_table_view = QtWidgets.QTableView(self.centralwidget)

so my actual tableview with the code in and such already exists.


class SurveyTableView(QTableView):
    def __init__(self, headers, dataList,  parent=None):
        super(SurveyTableView, self).__init__(parent)
        self.table_model = SurveyTableModel(self, dataList, headers)
        self.setModel(self.table_model)

so how do i tell pyqt that that it should use that view instead?

self.ui.surveys_table_view = SurveyTableView(header, dataList, self.ui.centralwidget)

or

self.ui.surveys_table_view = SurveyTableView(self) 
# self throws it into the top of the mainwindow and not promoting it,
self.ui.surveys_table_view = SurveyTableView()
# does nothing

do note that i have some predefined data that i tested running just the view and model in a standalone window and they function as intended

would it be better just to remove the tableview from the designer as whole and just add a widget to the layout? but with this step it feels like the whole point of using a gui creator grows irrelevant so i am sure there must be a more py(qt)thonic to do this.

question was unruly closed as i am doing what the example provided Customising code of Qt designer widget?

Fanna1119
  • 1,878
  • 4
  • 24
  • 30

0 Answers0