title: How to display table from SQLite database in QTableView widget?
body: <p>I created a SQLite database called "test.db". It has only one table called "table1" which is not an empty table.
  I tried to display "table1" in QTableView widget but the widget displayed nothing. 
  The database was connected and Qt Createor didn't detect any error. I don't understand why QTableView displayed nothing at all.</p>
  
  <p>My Code:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  
  #include &lt;QtCore&gt;
  #include &lt;QSqlDatabase&gt;
  #include &lt;QSqlTableModel&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::MainWindow)
  
  {
    ui-&gt;setupUi(this);
  
    QSqlDatabase test = QSqlDatabase::addDatabase("QSQLITE");
    test.setDatabaseName("test.db");
  
    if (test.open())
    {
      ui-&gt;DB_Status-&gt;setText("DB is connected.");
    }
    else
    {
      ui-&gt;DB_Status-&gt;setText("DB is not connected.");
    }
  
    QSqlTableModel *model = new QSqlTableModel(this,test);
    model-&gt;setTable("table1");
    model-&gt;setEditStrategy(QSqlTableModel::OnManualSubmit);
    model-&gt;select();
    model-&gt;setHeaderData(0, Qt::Horizontal, tr("Row1"));
    model-&gt;setHeaderData(1, Qt::Horizontal, tr("Row2"));
  
    ui-&gt;tableView-&gt;setModel(model);
    ui-&gt;tableView-&gt;show();
  }
  </code></pre>
  
  <p>I can run the program but QTableView widget diaplay nothing. Where is the problem ?</p>