I've written this piece of code which takes the contents of a QPlainTextEditor and then sends that to a QPrint object it the the user accepts QPrintDialog
void MainWindow::on_actionPrint_triggered()
{
printPage = new QPrinter(QPrinter::HighResolution);
QPrintDialog *printDialog = new QPrintDialog(printPage,this);
printDialog->show();
if(printDialog->exec() == QPrintDialog::Accepted){
QPainter *painterToPrnt = new QPainter;
painterToPrnt->begin(printPage);
painterToPrnt->drawText(printPage->pageRect(),ui->plainTextEdit->toPlainText());
painterToPrnt->end();
}
}
it works OK under KDE (didn't try that under Gnome), but in Windows, whenever I accepts the printDialog, the dialog will be shown again and if I accept that again, it will send the text to the printer.
how can I fix that?