微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Qt:使用 QPainter::begin() 处理“将打印输出另存为”对话框

如何解决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 文件正在使用中(例如在 Adob​​e Reader 中打开)?

我已经尝试检查 printer.outputFormat()printer.docName(),但它们都是空的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。