here is a minimal reproducable example of my problem:
#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();
}
My question is - as already mentioned in the code - how do I know if the dialog is canceled by the user or the pdf file is just in use (for example opened in Adobe Reader)?
I already tried to check the printer.outputFormat()
and the printer.docName()
but they are both empty.