QPainter :: begin:绘制设备返回引擎== 0,键入:2

时间:2016-10-29 17:47:15

标签: c++ qt qpainter

我试图打印Qtablewidget,但它只是打印一个空白页面和应用程序输出显示

QPrinter::metric: Invalid metric command
QPainter::begin: Paint device returned engine == 0, type: 2
QWidget::render: Cannot render with an inactive painter

打印功能

void MainWindow::on_btPrint_clicked(){
  QPrinter printer(QPrinter::HighResolution);
  QPrintDialog printer_dialog(&printer, this);
  if (printer_dialog.exec() == QDialog::Rejected) return;
  QPainter painter(&printer);
  ui->table_log->render(&painter);
}

log table

1 个答案:

答案 0 :(得分:0)

由set painter.scale修复

'Calculating Sum of Max. values of Eth column from pivot table values
    Dim lastRowE As Long
    lastRowE = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
    'Excluding grandtotal
    lastRowE = lastRowE - 1
    Worksheets("pmrrcconnmax").Activate
    Cells(1, 5).Value = WorksheetFunction.SumIfs(Range("E7:E" & lastRowE), _
                                        Range("E7:E" & lastRowE), ">0")

 'Calculating Sum of Max. values of Fth column from pivot table values
    'Dim lastRowF As Long
    lastRowF = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
    'Excluding grandtotal
    lastRowF = lastRowF - 1
    'Worksheets("pmrrcconnmax").Activate
    Cells(1, 6).Value = WorksheetFunction.SumIfs(Range("F7:F" & lastRowF), _
                                            Range("F7:F" & lastRowF), ">0")

'Calculating Sum of Max. values of Gth column from pivot table values
    'Dim lastRowG As Long
    lastRowG = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
    'Excluding grandtotal
    lastRowG = lastRowG - 1
    'Worksheets("pmrrcconnmax").Activate
    Cells(1, 7).Value = WorksheetFunction.SumIfs(Range("G7:G" & lastRowG), _
                                         Range("G7:G" & lastRowG), ">0")

Printing Widgets