title: QPushButton in QTableView
body: <p>I'm working on a project where i'm trying to add a QPushButton into a QTableView.
  also i want to connect that button to open a document from a database. So far i added the button and i wrote the connect statement for it but when i click on the button nothing happened.</p>
  
  <p>here is my code </p>
  
  <pre><code>void MainWindow::DocumentTable()
  {
  tableview = new QTableView;
  query = new QSqlQueryModel(this);
  signalMapper = new QSignalMapper(this);
  
  foreach(it,treeWidget-&gt;selectedItems())
  {
      for (int col=0; col&lt; it-&gt;columnCount(); ++col)
      {
          qDebug() &lt;&lt; col &lt;&lt; it-&gt;text(col);
  
  QSqlQuery qry;
  qry.prepare("select * from document where Folno=:Folno");
  qry.bindValue(":Folno", it-&gt;text(col));
  qry.exec();
  
  
  query-&gt;setQuery(qry);
  tableview-&gt;setModel(query);
  tableview-&gt;setEditTriggers(QAbstractItemView::NoEditTriggers);
  
  for (int i = 0; i&lt; 1000; i++)
  {
      button= new QPushButton("Open Document");
      tableview-&gt;setIndexWidget(tableview-&gt;model()-&gt;index(i, 0), button);
      signalMapper-&gt;setMapping(button, i);
  }
  
  connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(imageFROMdatabase()));
  
  tableview-&gt;show();
  
  Docwidget= new QDockWidget(this);
  Docwidget-&gt;setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  
  Docwidget-&gt;setWidget(tableview);
  addDockWidget(Qt::RightDockWidgetArea,Docwidget);
  
  Docwidget-&gt;show();
  
  if(!query-&gt;submit())
    {
       QMessageBox::warning(0,"Error",query-&gt;lastError().text());
  
    }
  
   db.close();
  
  }
  
           }
            }
  </code></pre>
  
  <p>and this is the slot function </p>
  
  <pre><code>   void MainWindow::imageFROMdatabase()
   {
  
  
  QSqlQuery imageQuery;
  
  imageQuery.prepare("SELECT * from doc_page where doc_no=:doc_no and f_number=:f_number");
  imageQuery.bindValue(":doc_no", 1);
  imageQuery.bindValue(":f_number",1);
  imageQuery.exec();
  imageQuery.next();
  
  if( imageQuery.lastError().isValid())
      {
      QMessageBox::warning(0,"Error",imageQuery.lastError().text());
  
    //  QSqlDatabase::database().rollback();
       }
  else
  {
     // QByteArray ba1 = imageQuery.value(1).toByteArray();
      QPixmap pic;
      pic.loadFromData( ba);
  
  scrollArea = new QScrollArea;
  scrollArea-&gt;setBackgroundRole(QPalette::Dark);
  scrollArea-&gt;setEnabled(true);
  
  QString fileName = QFileDialog::getOpenFileName(this,"Open Image File",QDir::currentPath());
  QImage image(fileName);
  
  scene = new QGraphicsScene();
  view = new QGraphicsView(scene);
  item = new QGraphicsPixmapItem(QPixmap::fromImage(image));
  scene-&gt;addItem(item);
  
       xwidget= new QDockWidget(this);
       xwidget-&gt;setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
  
       xwidget-&gt;setWidget(view);
       addDockWidget(Qt::RightDockWidgetArea,xwidget);
       xwidget-&gt;show();
  
       db.close();
       }
   }
  </code></pre>
  
  <p>please tell if anything wrong in these codes. </p>