qt - Qt:使用 QPainter::begin() 处理“将打印输出另存为”对话框
问题描述
这是我的问题的最小可重现示例:
#include <QCoreApplication>
#include <QtPrintSupport/QPrinter>
#include <QPainter>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QPrinter printer;
QPainter painter;
// this will open a file dialog to save a pdf file
if (!painter.begin(&printer)) {
qDebug() << "how to get the difference between 'Dialog Canceled' and 'File in use' here?";
}
else {
//do the painting stuf...
}
return a.exec();
}
我的问题是 - 正如代码中已经提到的 - 我如何知道对话框是否被用户取消或 pdf 文件正在使用中(例如在 Adobe Reader 中打开)?
我已经尝试检查printer.outputFormat()
and theprinter.docName()
但它们都是空的。
解决方案
推荐阅读
- html - 整页宽度和高度中的 bing 地图
- mysql - 在sql中查找具有相同ID且条件相同的值的总和
- yolo - 训练好的YOLO,yolo_best.weights有哪个迭代?
- swift - 从 NavigationView 层次结构 SwiftUI 中的子视图调用 NotificationCenter.default.publisher
- java - 有没有办法隐藏标题栏,但保留 JFrame 中的按钮
- java - 用于单元测试的模拟 livy 服务器
- javascript - 如何在javascript中为所有属性覆盖getter和setter?
- python - python 是否将 no return 语句视为与 return None 完全相同?
- ios - 有没有办法在 Swift 中使用导航链接加载函数?
- png - 如何使用 pydicom.read_file() 和 cv2.imread() 一次读取多个 DICOM 和 PNG 文件?