title: QTableView does not display data from QSqlTableModel using PySide/PyQt
body: <p>I have already found similar problems on the net, unfortunately the offered solutions did not work for me.</p>
  <p>I'm trying to display tabular data from an SQLite database via the QTableView. The connection to the database seems to work in principle (I was able to query via QSql - so the database is not empty and the connection is established).</p>
  <p>I've tried to include the database connection into the <strong>init</strong> method of the MainWindow before instantiating the QSqlModel. That had no effect. I also tried passing my database connection as an argument when instantiating the QSqlModel. That didn't do anything either.</p>
  <p>So somehow my Model doesn't know anything about my database, but I have no more ideas what it could be.</p>
  <pre><code>import sys
  from PySide6 import QtWidgets
  from PySide6 import QtSql
  from PySide6 import QtGui
  from PySide6.QtCore import Qt
  
  class MainWindow(QtWidgets.QMainWindow):
      def __init__(self):
          super().__init__()
  
          self.model = QtSql.QSqlTableModel()
          self.model.setTable(&quot;Names&quot;)
          self.model.select()
  
          self.table = QtWidgets.QTableView()
          self.table.setModel(self.model)
          self.setCentralWidget(self.table)
  
  
  if __name__ == &quot;__main__&quot;:
      app = QtWidgets.QApplication()
      db_connection = QtSql.QSqlDatabase(&quot;QSQLITE&quot;)
      db_connection.setDatabaseName(&quot;test_db.db&quot;)
  
      if not db_connection.open():
          QtWidgets.QMessageBox.critical(
              None,
              &quot;App Name - Error!&quot;,
              &quot;Database Error: %s&quot; % db_connection.lastError().databaseText(),
          )
          sys.exit(1)
  
      window = MainWindow()
      window.show()
      app.exec()
  
  </code></pre>