What look a bit strange for me is that you have two instances of QTableView and two instances of QSqlTableModel.

Most likely the returned instance of QTableView of the method QTableView *database::initializeModel(QSqlTableModel *model) is senceless.

Use the instance in the ui-class instead.

Good luck