如何解决为什么将文档打印为PDF会崩溃?
我正在尝试运行从QtWiki用Qt生成pdf的官方示例,但是它崩溃了,代码为-1073740940
。它发生在以下行:QPrinter printer(QPrinter::PrinterResolution);
printsupport
已添加到项目文件。
我没有更改示例代码中的任何内容:
#include <QtWidgets>
#ifndef QT_NO_PRINTER
#include <QPrinter>
#endif
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QString fileName = QFileDialog::getSaveFileName((QWidget* )0,"Export PDF",QString(),"*.pdf");
if (QFileInfo(fileName).suffix().isEmpty()) { fileName.append(".pdf"); }
QPrinter printer(QPrinter::PrinterResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFileName(fileName);
QTextDocument doc;
doc.setHtml("<h1>Hello,World!</h1>\n<p>Lorem ipsum dolor sit amet,consectitur adipisci elit.</p>");
doc.setPageSize(printer.pageRect().size()); // This is necessary if you want to hide the page number
doc.print(&printer);
}
我在设备中安装了“ Microsoft打印到pdf”。
崩溃的可能是什么原因以及如何解决?
//在之后添加
我的设置:
Qt 5.14.1
MinGW 64 bit
Win 10 64 bit
调试器堆栈跟踪:
1 ntdll!RtlIsNonEmptyDirectoryReparsePointAllowed 0x7ffa1b1b91b3
2 ntdll!RtlpNtMakeTemporaryKey 0x7ffa1b1c15e2
3 ntdll!RtlpNtMakeTemporaryKey 0x7ffa1b1c18ea
4 ntdll!RtlpNtMakeTemporaryKey 0x7ffa1b1ca8a9
5 ntdll!RtlGetCurrentServiceSessionId 0x7ffa1b10253a
6 ntdll!RtlGetCurrentServiceSessionId 0x7ffa1b100790
7 ntdll!RtlFreeHeap 0x7ffa1b0ffb91
8 ntdll!RtlpNtMakeTemporaryKey 0x7ffa1b1c53c9
9 ntdll!memset 0x7ffa1b175670
10 ntdll!RtlGetCurrentServiceSessionId 0x7ffa1b100790
11 ntdll!RtlFreeHeap 0x7ffa1b0ffb91
12 msvcrt!free 0x7ffa19189cfc
13 QWindowsPrintDevice::defaultPageSize() const 0x6f882e41
14 QPrintDevice::defaultPageSize() const 0x6df43efd
15 QWin32PrintEngine::QWin32PrintEngine(QPrinter::PrinterMode,QString const&) 0x6df528b2
16 QWindowsPrinterSupport::createNativePrintEngine(QPrinter::PrinterMode,QString const&) 0x6f88169a
17 QPrinterPrivate::initEngines(QPrinter::OutputFormat,QPrinterInfo const&) 0x6df4a523
18 QPrinterPrivate::init(QPrinterInfo const&,QPrinter::PrinterMode) 0x6df4a70e
19 QPrinter::QPrinter(QPrinter::PrinterMode) 0x6df4a818
20 main main.cpp 13 0x4016cc
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。