Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
Description
On Mac / OS X the print dialog provides a PDF button with a "Save as PDF" option.
The default name provided is the name of the calling window. This works fine the first time the window is called, but subsequent calls to the same QPrinter from applications with different titles (for example different documents in a word processor) all suggest the same name as the first document.
The only work around is to recreate the QPrinter object each time and this will lose print settings.
Test case main.cpp to reproduce issue
====================================
#include <QtGui>
#include <QTextStream>
#include <QtWebKit>
//======================================
class MyWidget: public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
private slots:
void doSomething();
private:
void print();
QHBoxLayout *layout;
QPushButton *button;
QPrinter *printer;
int i;
};
//======================================
MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
setWindowTitle("Name");
layout = new QHBoxLayout;
button = new QPushButton ("Do Something");
layout->addWidget(button);
setLayout(layout);
printer = new QPrinter();
i = 1;
QObject::connect(button, SIGNAL(clicked()), this, SLOT(doSomething()));
}
//======================================
void MyWidget::doSomething()
{
printer->setDocName("BBB");
print();
}
//======================================
void MyWidget::print()
{
QPrintDialog *dlg = new QPrintDialog(printer, this);
if (dlg->exec() == QDialog::Accepted)
delete dlg; dlg=NULL;
i++;
setWindowTitle( QString("Name %1").arg );
//the following does not work either.
// printer->setOutputFileName( QString("Name %1").arg );
}
//======================================
//This moc name must match the name of the file to get objects into a single file
#include "main.moc"
//======================================
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget *myWin = new MyWidget();
myWin->show();
return app.exec();
}
//======================================
Attachments
Issue Links
- is required for
-
QTBUG-25379 QtPrintSupport - PDF Issues
- Open
-
QTBUG-25383 QtPrintSupport - macOS Issues
- Closed