Hello, everybody!
Please help with qprinter()
I'm sending 10 pages to printer, and I want to clear pending events to printer.
But printer.abort() doesn't work and its result is false;
what's problem?
maybe I need to connect additional libs or make some changes in .pro
there is a piece of my code:
void AbortPrinter::on_pushButton_clicked()
{
//to print
if(dialog
->exec
() == QDialog::Accepted) {
progressDialog->show();
painter->begin(&printer);
painter->setPen(Qt::white);
for(int i=0;i<10;i++)
{
painter->drawText(50,50,tr("HELLO DUDE! X))"));
if(i>0)
printer.newPage();
qDebug()<<"pending Events: "<<qApp->hasPendingEvents();
//if(qApp->hasPendingEvents()) - this version is also doesn't work correct
if(b) //b is global bool to check aborted printers
{
painter->end();
qDebug()<<"aborted: "<<b;
break;
}
}
painter->end();
}
}
void AbortPrinter::on_pushButton_2_clicked()
{//to abort
b = printer.abort();
}
void AbortPrinter::on_pushButton_clicked()
{
//to print
if(dialog->exec() == QDialog::Accepted)
{
progressDialog->show();
painter->begin(&printer);
painter->setPen(Qt::white);
for(int i=0;i<10;i++)
{
painter->drawText(50,50,tr("HELLO DUDE! X))"));
if(i>0)
printer.newPage();
qDebug()<<"pending Events: "<<qApp->hasPendingEvents();
qApp->processEvents(QEventLoop::AllEvents);
//if(qApp->hasPendingEvents()) - this version is also doesn't work correct
if(b) //b is global bool to check aborted printers
{
painter->end();
qDebug()<<"aborted: "<<b;
break;
}
}
painter->end();
}
}
void AbortPrinter::on_pushButton_2_clicked()
{//to abort
b = printer.abort();
}
To copy to clipboard, switch view to plain text mode
Bookmarks