PDA

View Full Version : Problem with setting QPrinter margins through QPageSetupDialog



Raadush
28th May 2012, 11:42
Hi, I have this simple code:



QPrinter *printer;
QPageSetupDialog *pageSetup;

//(those two variables are initialized in constructor method of CardManager)

void CardManager::printSetup()
{
pageSetup = new QPageSetupDialog(printer, this);
pageSetup->exec();
}

void CardManager::print()
{
QPrintDialog *printDialog = new QPrintDialog(printer, this);
if (printDialog->exec() == QDialog::Accepted)
{
QTextDocument *document = new QTextDocument();
QString html = "something";
document->setHtml(html);
document->print(printer);
}
}


When I setup paper size by printSetup() and then call print(), the paper size (meaning A4, A5 etc.) is remembered. But when I setup page margins by printSetup() and then call print(), margins are set to their default values (and so not remembered how they were set up by printSetup()). Any help with that?