PDA

View Full Version : QPrintDialog - cannot enable page range selection, Win XP - Qt 4.3.0



Quid
11th September 2007, 03:29
Greetings,

So I have one problem that I cannot seem to figure out no matter how much I tinker with my print code.

How do you get the specify page range option to appear enabled in the print dialog?

No matter what I try my print dialog specify page range comes up disabled and will not allow me to print only part of a report. I have tried running the app on numerous machines with no luck.

Platform: Win XP
Qt: 4.3.0 Commercial

Here is a snippet of my code:



QPrinter printer(QPrinter::HighResolution);
QPageSetupDialog pageSetupDlg(&printer);
pageSetupDlg.exec();
printer.setFullPage(true);

QPrintDialog *dlg = new QPrintDialog(&printer, this);
dlg->addEnabledOption(QAbstractPrintDialog::PrintPageRa nge);
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelect ion);
dlg->addEnabledOption(QAbstractPrintDialog::PrintToFile );

if(dlg->exec() == QDialog::Rejected)
{
delete dlg;
return;
}


Any information would be appreciated.

~Cheers

Quid

marcel
11th September 2007, 07:43
On Windows and Mac OS X, the native print dialog is used, which means that some QWidget and QDialog properties set on the dialog won't be respected. In addition, the native print dialog on Mac OS X does not support setting printer options, i.e. QAbstractPrintDialog::setEnabledOptions() and QAbstractPrintDialog::addEnabledOption() have no effect.

So I suggest you use the Win print dialog API to enable those options. It is a bit obscure, but you can get it to work.

Regards