title: QPainter::begin: Paint device returned engine == 0, type: 2
body: <p>I'm trying to print Qtablewidget but it just print a blank page and application output show</p>
  
  <pre><code>QPrinter::metric: Invalid metric command
  QPainter::begin: Paint device returned engine == 0, type: 2
  QWidget::render: Cannot render with an inactive painter
  </code></pre>
  
  <p>print function</p>
  
  <pre><code>void MainWindow::on_btPrint_clicked(){
    QPrinter printer(QPrinter::HighResolution);
    QPrintDialog printer_dialog(&amp;printer, this);
    if (printer_dialog.exec() == QDialog::Rejected) return;
    QPainter painter(&amp;printer);
    ui-&gt;table_log-&gt;render(&amp;painter);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/l9Rph.png" rel="nofollow"><img src="https://i.stack.imgur.com/l9Rph.png" alt="log table"></a></p>